本文整理匯總了Golang中github.com/gin-gonic/gin.Engine.DELETE方法的典型用法代碼示例。如果您正苦於以下問題:Golang Engine.DELETE方法的具體用法?Golang Engine.DELETE怎麽用?Golang Engine.DELETE使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/gin-gonic/gin.Engine
的用法示例。
在下文中一共展示了Engine.DELETE方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: registerRoutes
func registerRoutes(e *gin.Engine) {
controller := rc.ResourceController{}
controller.DatabaseProvider = Database
resourceNames := []string{"RecordMatchContext",
"RecordMatchSystemInterface", "RecordSet"}
for _, name := range resourceNames {
e.GET("/"+name+"/:id", controller.GetResource)
e.POST("/"+name, controller.CreateResource)
e.PUT("/"+name+"/:id", controller.UpdateResource)
e.DELETE("/"+name+"/:id", controller.DeleteResource)
e.GET("/"+name, controller.GetResources)
}
e.POST("/AnswerKey", controller.SetAnswerKey)
name := "RecordMatchRun"
e.GET("/"+name, controller.GetResources)
e.GET("/"+name+"/:id", controller.GetResource)
e.POST("/"+name, rc.CreateRecordMatchRunHandler(Database))
e.PUT("/"+name+"/:id", controller.UpdateResource)
e.DELETE("/"+name+"/:id", controller.DeleteResource)
e.GET("/RecordMatchRunMetrics", rc.GetRecordMatchRunMetricsHandler(Database))
e.GET("/RecordMatchRunLinks/:id", rc.GetRecordMatchRunLinksHandler(Database))
e.Static("/ptmatch/api/", "api")
}
示例2: RegisterRoutes
func RegisterRoutes(r *gin.Engine) {
r.GET("/", func(c *gin.Context) {
// c.String(http.StatusOK, "this is our home page")
c.HTML(http.StatusOK, "index.html", nil)
})
// --------------------------- user apis ---------------
r.POST("/v1/users", controllers.User_new)
r.GET("/v1/users/:userId", controllers.User_get)
r.PUT("/v1/users/:userId", controllers.User_update)
r.DELETE("/v1/users/:userId", controllers.User_delete)
// --------------------------- system apis ---------------
r.GET("/sys/install", controllers.Sys_getInstall)
r.POST("/sys/install", controllers.Sys_install)
}
示例3: RegisterHandlers
func (h *UserHandlers) RegisterHandlers(g *gin.Engine) {
g.GET("/user", h.All)
g.GET("/user/:id", h.GetUser)
g.PUT("/user", h.CreateUser)
g.POST("/user/:id", h.UpdateUser)
g.DELETE("/user/:id", h.DeleteUser)
g.POST("/user/:id/password", h.ChangePassword)
}
示例4: Controller
// Controller for taxonomies resources
func Controller(r *gin.Engine, db *sql.DB) {
r.GET("/taxonomies", func(c *gin.Context) {
taxonomies, err := ListAllTaxonomies(db)
if err != nil {
c.AbortWithError(400, err)
return
}
c.Header("Content-Type", "application/json")
c.String(200, taxonomies)
})
r.POST("/taxonomy", func(c *gin.Context) {
tax := new(Taxonomy)
err := c.BindJSON(&tax)
if err != nil {
c.Error(err)
return
}
err = CreateTaxonomy(tax, db)
if err != nil {
c.AbortWithError(400, err)
return
}
c.String(200, "")
})
r.DELETE("/taxonomy/:id", func(c *gin.Context) {
defer func() {
if r := recover(); r != nil {
c.AbortWithError(400, r.(error))
}
}()
id := getID(c)
err := DeleteTaxonomy(id, db)
if err != nil {
panic(err)
}
c.String(200, "")
})
r.PUT("/taxonomy/:id", func(c *gin.Context) {
defer func() {
if r := recover(); r != nil {
c.AbortWithError(400, r.(error))
}
}()
id := getID(c)
tax := new(Taxonomy)
err := c.BindJSON(&tax)
if err != nil {
panic(err)
}
err = UpdateTaxonomy(id, tax, db)
if err != nil {
c.AbortWithError(400, err)
return
}
c.String(200, "")
})
}
示例5: RegisterRoutes
func (tr *TemplatesResource) RegisterRoutes(c *gin.Engine) {
c.GET("/api/templates", tr.Index)
c.GET("/api/templates/:id", tr.Show)
c.POST("/api/templates", tr.Create)
c.POST("/api/templates/:id", tr.Update)
c.PUT("/api/templates/:id", tr.Update)
c.DELETE("/api/templates/:id", tr.Delete)
c.POST("/api/templates/:id/convert", tr.Convert)
c.POST("/api/convert", tr.ConvertRaw)
}
示例6: Register
func Register(engine *gin.Engine) {
engine.Use(Recovery)
engine.Use(Errors)
engine.GET("/events", eventsGet)
engine.GET("/profile", profileGet)
engine.POST("/profile", profilePost)
engine.DELETE("/profile", profileDel)
engine.GET("/ping", pingGet)
engine.POST("/stop", stopPost)
engine.GET("/status", statusGet)
}
示例7: DeleteUserHttpSession
func DeleteUserHttpSession(db gorm.DB, router *gin.Engine) {
router.DELETE("/user_http_session/:id", func(c *gin.Context) {
_id := c.Param("id")
if id, err := strconv.ParseUint(_id, 10, 64); err == nil {
user_http_session := &model.UserHttpSession{
UserHttpSessionId: model.UserHttpSessionId{Id: id},
}
if err := db.First(user_http_session).Error; err == nil {
db.Delete(user_http_session)
c.AbortWithStatus(http.StatusOK)
} else {
c.AbortWithStatus(http.StatusNotFound)
}
} else {
log.Print(err)
c.AbortWithError(http.StatusBadRequest, err)
}
})
}
示例8: DeleteLike
func DeleteLike(db gorm.DB, router *gin.Engine) {
router.DELETE("/like/:id", func(c *gin.Context) {
_id := c.Param("id")
if id, err := strconv.ParseUint(_id, 10, 64); err == nil {
like := &model.Like{
LikeId: model.LikeId{Id: id},
}
if err := db.First(like).Error; err == nil {
db.Delete(like)
c.AbortWithStatus(http.StatusOK)
} else {
c.AbortWithStatus(http.StatusNotFound)
}
} else {
log.Print(err)
c.AbortWithError(http.StatusBadRequest, err)
}
})
}
示例9: DeleteWallEntry
func DeleteWallEntry(db gorm.DB, router *gin.Engine) {
router.DELETE("/wall_entry/:id", func(c *gin.Context) {
_id := c.Param("id")
if id, err := strconv.ParseUint(_id, 10, 64); err == nil {
wall_entry := &model.WallEntry{
WallEntryId: model.WallEntryId{Id: id},
}
if err := db.First(wall_entry).Error; err == nil {
db.Delete(wall_entry)
c.AbortWithStatus(http.StatusOK)
} else {
c.AbortWithStatus(http.StatusNotFound)
}
} else {
log.Print(err)
c.AbortWithError(http.StatusBadRequest, err)
}
})
}
示例10: DeleteGroupAdmin
func DeleteGroupAdmin(db gorm.DB, router *gin.Engine) {
router.DELETE("/group_admin/:id", func(c *gin.Context) {
_id := c.Param("id")
if id, err := strconv.ParseUint(_id, 10, 64); err == nil {
group_admin := &model.GroupAdmin{
GroupAdminId: model.GroupAdminId{Id: id},
}
if err := db.First(group_admin).Error; err == nil {
db.Delete(group_admin)
c.AbortWithStatus(http.StatusOK)
} else {
c.AbortWithStatus(http.StatusNotFound)
}
} else {
log.Print(err)
c.AbortWithError(http.StatusBadRequest, err)
}
})
}
示例11: Mount
//Mount mount routes
func (p *Engine) Mount(r *gin.Engine) {
ag := r.Group("/admin", p.Jwt.CurrentUserHandler(true), p.Jwt.MustAdminHandler())
ag.GET("/site/info", p.getAdminSiteInfo)
ag.POST("/site/info", web.Rest(p.postAdminSiteInfo))
ag.DELETE("/cache", web.Rest(p.deleteAdminCache))
ag.GET("/notices", web.Rest(p.getNotices))
ag.POST("/notices", web.Rest(p.postNotices))
ag.DELETE("/notices/:id", web.Rest(p.deleteNotice))
r.GET("/notices", p.Cache.Page(time.Hour*24, web.Rest(p.getNotices)))
r.GET("/personal/self", p.Jwt.CurrentUserHandler(true), web.Rest(p.getPersonalSelf))
r.GET("/personal/logs", p.Jwt.CurrentUserHandler(true), web.Rest(p.getPersonalLogs))
r.DELETE("/personal/signOut", p.Jwt.CurrentUserHandler(true), p.deleteSignOut)
r.GET("/locales/:lang", p.Cache.Page(time.Hour*24, p.getLocale))
r.GET("/site/info", p.Cache.Page(time.Hour*24, p.getSiteInfo))
r.POST("/oauth2/callback", web.Rest(p.postOauth2Callback))
}
示例12: DeleteSpaceSetting
func DeleteSpaceSetting(db gorm.DB, router *gin.Engine) {
router.DELETE("/space_setting/:id", func(c *gin.Context) {
_id := c.Param("id")
if id, err := strconv.ParseUint(_id, 10, 64); err == nil {
space_setting := &model.SpaceSetting{
SpaceSettingId: model.SpaceSettingId{Id: id},
}
if err := db.First(space_setting).Error; err == nil {
db.Delete(space_setting)
c.AbortWithStatus(http.StatusOK)
} else {
c.AbortWithStatus(http.StatusNotFound)
}
} else {
log.Print(err)
c.AbortWithError(http.StatusBadRequest, err)
}
})
}
示例13: DeleteModuleEnabled
func DeleteModuleEnabled(db gorm.DB, router *gin.Engine) {
router.DELETE("/module_enabled/:id", func(c *gin.Context) {
_id := c.Param("id")
if id, err := strconv.ParseUint(_id, 10, 64); err == nil {
module_enabled := &model.ModuleEnabled{
ModuleEnabledId: model.ModuleEnabledId{Id: id},
}
if err := db.First(module_enabled).Error; err == nil {
db.Delete(module_enabled)
c.AbortWithStatus(http.StatusOK)
} else {
c.AbortWithStatus(http.StatusNotFound)
}
} else {
log.Print(err)
c.AbortWithError(http.StatusBadRequest, err)
}
})
}
示例14: Register
func Register(r *gin.Engine) {
r.Use(func(c *gin.Context) {
// Run this on all requests
// Should be moved to a proper middleware
c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type,Token")
c.Next()
})
r.GET("/", func(c *gin.Context) {
c.String(200, "Y'all ready for this? \n\nOh no! They were ready for that.")
//c.JSON(200, gin.H{"Pong": "Ping"})
})
//Auth
authHandler := new(handlers.CCAuthHandler)
r.POST("/auth/login", authHandler.BasicAuth)
//Middleware
// r.Use(authHandler.TokenAuthMiddleware())
// User routes
userApi := new(api.CCUser)
r.GET("/user", userApi.Get)
r.POST("/user", userApi.Post)
r.DELETE("/user", userApi.Delete)
// Program routes
programApi := new(api.CCProgram)
r.GET("/program", programApi.Get)
r.POST("/program", programApi.Post)
r.DELETE("/program", programApi.Delete)
// Event routes
eventApi := new(api.CCEvent)
r.GET("/event", eventApi.Get)
r.POST("/event", eventApi.Post)
r.PUT("/event/edit", eventApi.Edit)
r.DELETE("/event", eventApi.Delete)
// Volunteer routes
volunteerApi := new(api.CCVolunteer)
r.GET("/event/volunteer", volunteerApi.Get)
r.POST("/event/volunteer", volunteerApi.Post)
r.PUT("/event/volunteer/log", volunteerApi.LogTime)
r.DELETE("/event/volunteer", volunteerApi.Delete)
// Moments routes
momentApi := new(api.CCMoment)
r.GET("/event/moment", momentApi.Get)
r.DELETE("/event/moment", momentApi.Delete)
r.POST("/event/moment", momentApi.Post)
//Rating
r.POST("/event/moment/rate", momentApi.Rate)
//Credits
r.GET("/event/moment/credit", momentApi.Credit)
//Image Upload
//Auth
uploadHandler := new(handlers.CCUploadHandler)
r.POST("/upload", uploadHandler.Upload)
}