PostsDelete done
This commit is contained in:
@@ -85,3 +85,14 @@ func PostsUpdate(c *gin.Context) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func PostsDelete(c *gin.Context) {
|
||||||
|
// Get the id off the url
|
||||||
|
id := c.Param("id")
|
||||||
|
|
||||||
|
// Delete the posts
|
||||||
|
initializers.DB.Delete(&models.Post{}, id)
|
||||||
|
|
||||||
|
// Responmd
|
||||||
|
c.Status(200)
|
||||||
|
}
|
||||||
|
|||||||
1
main.go
1
main.go
@@ -18,6 +18,7 @@ func main() {
|
|||||||
r.PUT("/posts/:id", controllers.PostsUpdate)
|
r.PUT("/posts/:id", controllers.PostsUpdate)
|
||||||
r.GET("/posts", controllers.PostsIndex)
|
r.GET("/posts", controllers.PostsIndex)
|
||||||
r.GET("/posts/:id", controllers.PostsShow)
|
r.GET("/posts/:id", controllers.PostsShow)
|
||||||
|
r.DELETE("/posts/:id", controllers.PostsDelete)
|
||||||
|
|
||||||
r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
|
r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user