本文整理匯總了Golang中github.com/gin-gonic/gin.Engine.PUT方法的典型用法代碼示例。如果您正苦於以下問題:Golang Engine.PUT方法的具體用法?Golang Engine.PUT怎麽用?Golang Engine.PUT使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/gin-gonic/gin.Engine
的用法示例。
在下文中一共展示了Engine.PUT方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: PutSpaceSetting
func PutSpaceSetting(db gorm.DB, router *gin.Engine) {
// PUT /space_setting
// Update space_setting data by id
router.PUT("/space_setting/:id", func(c *gin.Context) {
_id := c.Param("id")
if id, err := strconv.ParseUint(_id, 10, 64); err == nil {
var space_settingData model.SpaceSettingData
if err := c.BindJSON(&space_settingData); err == nil {
space_setting := &model.SpaceSetting{
SpaceSettingData: space_settingData,
SpaceSettingId: model.SpaceSettingId{Id: id},
}
if err := checkDataSpaceSetting(space_setting.SpaceSettingData); err {
checkSpaceSetting := &model.SpaceSetting{
SpaceSettingData: space_settingData,
SpaceSettingId: model.SpaceSettingId{Id: id},
}
if err := db.First(checkSpaceSetting).Error; err == nil {
db.Save(&space_setting)
c.JSON(http.StatusOK, space_setting)
} else {
c.AbortWithStatus(http.StatusNotFound)
}
} else {
c.AbortWithStatus(http.StatusBadRequest)
}
}
} else {
log.Print(err)
c.AbortWithError(http.StatusBadRequest, err)
}
})
}
示例2: PutUserHttpSession
func PutUserHttpSession(db gorm.DB, router *gin.Engine) {
// PUT /user_http_session
// Update user_http_session data by id
router.PUT("/user_http_session/:id", func(c *gin.Context) {
_id := c.Param("id")
if id, err := strconv.ParseUint(_id, 10, 64); err == nil {
var user_http_sessionData model.UserHttpSessionData
if err := c.BindJSON(&user_http_sessionData); err == nil {
user_http_session := &model.UserHttpSession{
UserHttpSessionData: user_http_sessionData,
UserHttpSessionId: model.UserHttpSessionId{Id: id},
}
if err := checkDataUserHttpSession(user_http_session.UserHttpSessionData); err {
checkUserHttpSession := &model.UserHttpSession{
UserHttpSessionData: user_http_sessionData,
UserHttpSessionId: model.UserHttpSessionId{Id: id},
}
if err := db.First(checkUserHttpSession).Error; err == nil {
db.Save(&user_http_session)
c.JSON(http.StatusOK, user_http_session)
} else {
c.AbortWithStatus(http.StatusNotFound)
}
} else {
c.AbortWithStatus(http.StatusBadRequest)
}
}
} else {
log.Print(err)
c.AbortWithError(http.StatusBadRequest, err)
}
})
}
示例3: PutActivity
func PutActivity(db gorm.DB, router *gin.Engine) {
// PUT /activity
// Update activity data by id
router.PUT("/activity/:id", func(c *gin.Context) {
_id := c.Param("id")
if id, err := strconv.ParseUint(_id, 10, 64); err == nil {
var activityData model.ActivityData
if err := c.BindJSON(&activityData); err == nil {
activity := &model.Activity{
ActivityData: activityData,
ActivityId: model.ActivityId{Id: id},
}
if err := checkDataActivity(activity.ActivityData); err {
checkActivity := &model.Activity{
ActivityData: activityData,
ActivityId: model.ActivityId{Id: id},
}
if err := db.First(checkActivity).Error; err == nil {
db.Save(&activity)
c.JSON(http.StatusOK, activity)
} else {
c.AbortWithStatus(http.StatusNotFound)
}
} else {
c.AbortWithStatus(http.StatusBadRequest)
}
}
} else {
log.Print(err)
c.AbortWithError(http.StatusBadRequest, err)
}
})
}
示例4: PutGroupAdmin
func PutGroupAdmin(db gorm.DB, router *gin.Engine) {
// PUT /group_admin
// Update group_admin data by id
router.PUT("/group_admin/:id", func(c *gin.Context) {
_id := c.Param("id")
if id, err := strconv.ParseUint(_id, 10, 64); err == nil {
var group_adminData model.GroupAdminData
if err := c.BindJSON(&group_adminData); err == nil {
group_admin := &model.GroupAdmin{
GroupAdminData: group_adminData,
GroupAdminId: model.GroupAdminId{Id: id},
}
if err := checkDataGroupAdmin(group_admin.GroupAdminData); err {
checkGroupAdmin := &model.GroupAdmin{
GroupAdminData: group_adminData,
GroupAdminId: model.GroupAdminId{Id: id},
}
if err := db.First(checkGroupAdmin).Error; err == nil {
db.Save(&group_admin)
c.JSON(http.StatusOK, group_admin)
} else {
c.AbortWithStatus(http.StatusNotFound)
}
} else {
c.AbortWithStatus(http.StatusBadRequest)
}
}
} else {
log.Print(err)
c.AbortWithError(http.StatusBadRequest, err)
}
})
}
示例5: PutNotification
func PutNotification(db gorm.DB, router *gin.Engine) {
// PUT /notification
// Update notification data by id
router.PUT("/notification/:id", func(c *gin.Context) {
_id := c.Param("id")
if id, err := strconv.ParseUint(_id, 10, 64); err == nil {
var notificationData model.NotificationData
if err := c.BindJSON(¬ificationData); err == nil {
notification := &model.Notification{
NotificationData: notificationData,
NotificationId: model.NotificationId{Id: id},
}
if err := checkDataNotification(notification.NotificationData); err {
checkNotification := &model.Notification{
NotificationData: notificationData,
NotificationId: model.NotificationId{Id: id},
}
if err := db.First(checkNotification).Error; err == nil {
db.Save(¬ification)
c.JSON(http.StatusOK, notification)
} else {
c.AbortWithStatus(http.StatusNotFound)
}
} else {
c.AbortWithStatus(http.StatusBadRequest)
}
}
} else {
log.Print(err)
c.AbortWithError(http.StatusBadRequest, err)
}
})
}
示例6: PutFile
func PutFile(db gorm.DB, router *gin.Engine) {
// PUT /file
// Update file data by id
router.PUT("/file/:id", func(c *gin.Context) {
_id := c.Param("id")
if id, err := strconv.ParseUint(_id, 10, 64); err == nil {
var fileData model.FileData
if err := c.BindJSON(&fileData); err == nil {
file := &model.File{
FileData: fileData,
FileId: model.FileId{Id: id},
}
if err := checkDataFile(file.FileData); err {
checkFile := &model.File{
FileData: fileData,
FileId: model.FileId{Id: id},
}
if err := db.First(checkFile).Error; err == nil {
db.Save(&file)
c.JSON(http.StatusOK, file)
} else {
c.AbortWithStatus(http.StatusNotFound)
}
} else {
c.AbortWithStatus(http.StatusBadRequest)
}
}
} else {
log.Print(err)
c.AbortWithError(http.StatusBadRequest, err)
}
})
}
示例7: PutUrlOembed
func PutUrlOembed(db gorm.DB, router *gin.Engine) {
// PUT /url_oembed
// Update url_oembed data by id
router.PUT("/url_oembed/:id", func(c *gin.Context) {
_id := c.Param("id")
if id, err := strconv.ParseUint(_id, 10, 64); err == nil {
var url_oembedData model.UrlOembedData
if err := c.BindJSON(&url_oembedData); err == nil {
url_oembed := &model.UrlOembed{
UrlOembedData: url_oembedData,
UrlOembedId: model.UrlOembedId{Id: id},
}
if err := checkDataUrlOembed(url_oembed.UrlOembedData); err {
checkUrlOembed := &model.UrlOembed{
UrlOembedData: url_oembedData,
UrlOembedId: model.UrlOembedId{Id: id},
}
if err := db.First(checkUrlOembed).Error; err == nil {
db.Save(&url_oembed)
c.JSON(http.StatusOK, url_oembed)
} else {
c.AbortWithStatus(http.StatusNotFound)
}
} else {
c.AbortWithStatus(http.StatusBadRequest)
}
}
} else {
log.Print(err)
c.AbortWithError(http.StatusBadRequest, err)
}
})
}
示例8: 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")
}
示例9: PutContent
func PutContent(db gorm.DB, router *gin.Engine) {
// PUT /content
// Update content data by id
router.PUT("/content/:id", func(c *gin.Context) {
_id := c.Param("id")
if id, err := strconv.ParseUint(_id, 10, 64); err == nil {
var contentData model.ContentData
if err := c.BindJSON(&contentData); err == nil {
content := &model.Content{
ContentData: contentData,
ContentId: model.ContentId{Id: id},
}
if err := checkDataContent(content.ContentData); err {
checkContent := &model.Content{
ContentData: contentData,
ContentId: model.ContentId{Id: id},
}
if err := db.First(checkContent).Error; err == nil {
db.Save(&content)
c.JSON(http.StatusOK, content)
} else {
c.AbortWithStatus(http.StatusNotFound)
}
} else {
c.AbortWithStatus(http.StatusBadRequest)
}
}
} else {
log.Print(err)
c.AbortWithError(http.StatusBadRequest, err)
}
})
}
示例10: 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)
}
示例11: PutModuleEnabled
func PutModuleEnabled(db gorm.DB, router *gin.Engine) {
// PUT /module_enabled
// Update module_enabled data by id
router.PUT("/module_enabled/:id", func(c *gin.Context) {
_id := c.Param("id")
if id, err := strconv.ParseUint(_id, 10, 64); err == nil {
var module_enabledData model.ModuleEnabledData
if err := c.BindJSON(&module_enabledData); err == nil {
module_enabled := &model.ModuleEnabled{
ModuleEnabledData: module_enabledData,
ModuleEnabledId: model.ModuleEnabledId{Id: id},
}
if err := checkDataModuleEnabled(module_enabled.ModuleEnabledData); err {
checkModuleEnabled := &model.ModuleEnabled{
ModuleEnabledData: module_enabledData,
ModuleEnabledId: model.ModuleEnabledId{Id: id},
}
if err := db.First(checkModuleEnabled).Error; err == nil {
db.Save(&module_enabled)
c.JSON(http.StatusOK, module_enabled)
} else {
c.AbortWithStatus(http.StatusNotFound)
}
} else {
c.AbortWithStatus(http.StatusBadRequest)
}
}
} else {
log.Print(err)
c.AbortWithError(http.StatusBadRequest, err)
}
})
}
示例12: PutLike
func PutLike(db gorm.DB, router *gin.Engine) {
// PUT /like
// Update like data by id
router.PUT("/like/:id", func(c *gin.Context) {
_id := c.Param("id")
if id, err := strconv.ParseUint(_id, 10, 64); err == nil {
var likeData model.LikeData
if err := c.BindJSON(&likeData); err == nil {
like := &model.Like{
LikeData: likeData,
LikeId: model.LikeId{Id: id},
}
if err := checkDataLike(like.LikeData); err {
checkLike := &model.Like{
LikeData: likeData,
LikeId: model.LikeId{Id: id},
}
if err := db.First(checkLike).Error; err == nil {
db.Save(&like)
c.JSON(http.StatusOK, like)
} else {
c.AbortWithStatus(http.StatusNotFound)
}
} else {
c.AbortWithStatus(http.StatusBadRequest)
}
}
} else {
log.Print(err)
c.AbortWithError(http.StatusBadRequest, err)
}
})
}
示例13: PutProfileFieldCategory
func PutProfileFieldCategory(db gorm.DB, router *gin.Engine) {
// PUT /profile_field_category
// Update profile_field_category data by id
router.PUT("/profile_field_category/:id", func(c *gin.Context) {
_id := c.Param("id")
if id, err := strconv.ParseUint(_id, 10, 64); err == nil {
var profile_field_categoryData model.ProfileFieldCategoryData
if err := c.BindJSON(&profile_field_categoryData); err == nil {
profile_field_category := &model.ProfileFieldCategory{
ProfileFieldCategoryData: profile_field_categoryData,
ProfileFieldCategoryId: model.ProfileFieldCategoryId{Id: id},
}
if err := checkDataProfileFieldCategory(profile_field_category.ProfileFieldCategoryData); err {
checkProfileFieldCategory := &model.ProfileFieldCategory{
ProfileFieldCategoryData: profile_field_categoryData,
ProfileFieldCategoryId: model.ProfileFieldCategoryId{Id: id},
}
if err := db.First(checkProfileFieldCategory).Error; err == nil {
db.Save(&profile_field_category)
c.JSON(http.StatusOK, profile_field_category)
} else {
c.AbortWithStatus(http.StatusNotFound)
}
} else {
c.AbortWithStatus(http.StatusBadRequest)
}
}
} else {
log.Print(err)
c.AbortWithError(http.StatusBadRequest, err)
}
})
}
示例14: PutWallEntry
func PutWallEntry(db gorm.DB, router *gin.Engine) {
// PUT /wall_entry
// Update wall_entry data by id
router.PUT("/wall_entry/:id", func(c *gin.Context) {
_id := c.Param("id")
if id, err := strconv.ParseUint(_id, 10, 64); err == nil {
var wall_entryData model.WallEntryData
if err := c.BindJSON(&wall_entryData); err == nil {
wall_entry := &model.WallEntry{
WallEntryData: wall_entryData,
WallEntryId: model.WallEntryId{Id: id},
}
if err := checkDataWallEntry(wall_entry.WallEntryData); err {
checkWallEntry := &model.WallEntry{
WallEntryData: wall_entryData,
WallEntryId: model.WallEntryId{Id: id},
}
if err := db.First(checkWallEntry).Error; err == nil {
db.Save(&wall_entry)
c.JSON(http.StatusOK, wall_entry)
} else {
c.AbortWithStatus(http.StatusNotFound)
}
} else {
c.AbortWithStatus(http.StatusBadRequest)
}
}
} else {
log.Print(err)
c.AbortWithError(http.StatusBadRequest, err)
}
})
}
示例15: PutPost
func PutPost(db gorm.DB, router *gin.Engine) {
// PUT /post
// Update post data by id
router.PUT("/post/:id", func(c *gin.Context) {
_id := c.Param("id")
if id, err := strconv.ParseUint(_id, 10, 64); err == nil {
var postData model.PostData
if err := c.BindJSON(&postData); err == nil {
post := &model.Post{
PostData: postData,
PostId: model.PostId{Id: id},
}
if err := checkDataPost(post.PostData); err {
checkPost := &model.Post{
PostData: postData,
PostId: model.PostId{Id: id},
}
if err := db.First(checkPost).Error; err == nil {
db.Save(&post)
c.JSON(http.StatusOK, post)
} else {
c.AbortWithStatus(http.StatusNotFound)
}
} else {
c.AbortWithStatus(http.StatusBadRequest)
}
}
} else {
log.Print(err)
c.AbortWithError(http.StatusBadRequest, err)
}
})
}