本文整理匯總了Golang中github.com/martini-contrib/binding.Form函數的典型用法代碼示例。如果您正苦於以下問題:Golang Form函數的具體用法?Golang Form怎麽用?Golang Form使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Form函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: BindArticleApi
func BindArticleApi(m *martini.ClassicMartini) {
m.Get("/api/article/latest", binding.Form(pagination{}), latestArticlesHandler)
m.Get("/api/article/hots", binding.Form(pagination{}), latestArticlesHandler)
m.Get("/api/article/comment", binding.Form(pagination{}), latestArticlesHandler)
m.Get("/api/article/update", binding.Form(pagination{}), latestArticlesHandler)
m.Get("/api/article/A:id", articleInfoHandler)
}
示例2: BindRecordApi
func BindRecordApi(m *martini.ClassicMartini) {
m.Post("/1/record/new",
binding.Json(newRecordForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
loadUserHandler,
checkLimitHandler,
newRecordHandler)
m.Get("/1/record/get",
binding.Form(getRecordForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
getRecordHandler)
m.Get("/1/record/timeline",
binding.Form(recTimelineForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
recTimelineHandler)
m.Get("/1/record/statistics",
binding.Form(userRecStatForm{}),
ErrorHandler,
userRecStatHandler)
m.Get("/1/leaderboard/list",
binding.Form(leaderboardForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
loadUserHandler,
leaderboardHandler)
m.Get("/1/leaderboard/gameList",
binding.Form(gamelbForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
gamelbHandler,
)
}
示例3: main
func main() {
m := martini.Classic()
m.Use(render.Renderer(render.Options{
Directory: "templates",
Extensions: []string{".tmpl", ".html"},
Charset: "UTF-8",
Funcs: []template.FuncMap{
{
"equal": func(args ...interface{}) bool {
return args[0] == args[1]
},
},
},
}))
store := sessions.NewCookieStore([]byte("secret123"))
m.Use(sessions.Sessions("my_session", store))
m.Get("/", youth)
m.Get("/firtConfirm", firtConfirm)
m.Post("/firtConfirm", binding.Form(model.User{}), firtConfirmPost)
m.Post("/userSiginCheck", binding.Bind(SiginIfo{}), userSiginCheck)
m.Get("/userInforEdit", userInforEdit)
m.Post("/userInforEdit", binding.Form(model.User{}), userInforEditPost)
m.Get("/editReruenInfo/:status", editReruenInfo)
m.Run()
}
示例4: main
func main() {
m := martini.Classic()
m.Use(render.Renderer(render.Options{
Layout: "layout",
}))
m.Use(DB())
m.Use(martini.Static("/css/"))
m.Get("/", func(r render.Render, db *mgo.Database) {
r.HTML(200, "list", All(db))
})
m.Post("/", binding.Form(Account{}), func(account Account, r render.Render, db *mgo.Database) {
db.C("accounts").Insert(account)
r.HTML(200, "list", All(db))
})
m.Post("/:accountName", binding.Form(Transaction{}), func(transaction Transaction, r render.Render, db *mgo.Database) {
db.C("transaction").Insert(transaction)
r.HTML(200, "display", Fetch(db, params["handle"]))
}
m.Get("/:handle", func(params martini.Params, r render.Render, db *mgo.Database) {
r.HTML(200, "display", Fetch(db, params["handle"]))
})
m.Run()
}
示例5: BindWalletApi
func BindWalletApi(m *martini.ClassicMartini) {
m.Get("/1/wallet/get",
binding.Form(walletForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
loadUserHandler,
getWalletHandler)
m.Get("/1/wallet/balance",
binding.Form(walletForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
loadUserHandler,
balanceHandler)
m.Get("/1/wallet/newaddr",
binding.Form(walletForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
loadUserHandler,
newAddrHandler)
m.Post("/1/wallet/send",
binding.Json(txForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
loadUserHandler,
checkLimitHandler,
txHandler)
m.Get("/1/wallet/txs",
binding.Form(addrTxsForm{}),
addrTxsHandler)
}
示例6: main
// Main function
func main() {
// Initializa config
config = &BareCVConfig{}
config.Load("../config.json")
// Initizalize database
db = InitDb()
// Initialize Martini
m = martini.Classic()
// Render html templates from templates directory
m.Use(render.Renderer(render.Options{
Extensions: []string{".html"},
Layout: "layout",
Funcs: []template.FuncMap{
{
"unescaped": func(args ...interface{}) template.HTML {
log.Printf("[main] unescaped: %s", args[0].(string))
urlStr, _ := url.QueryUnescape(args[0].(string))
return template.HTML(urlStr)
},
},
},
}))
// Initializes Google auth
InitGoogle()
// GET methods
m.Get("/", Home)
m.Get("/dashboard", oauth2.LoginRequired, Dashboard)
m.Get("/cv/:username", oauth2.LoginRequired, ShowPrivate)
m.Get("/cv", binding.Form(ProfileForm{}), oauth2.LoginRequired, CV)
m.Get("/sections", oauth2.LoginRequired, Sections)
m.Get("/sections/new/:type", oauth2.LoginRequired, SectionsNew)
m.Get("/sections/delete/:section_id", oauth2.LoginRequired, SectionsDelete)
m.Get("/sections/:type/:section_id", oauth2.LoginRequired, SectionsUpdate)
m.Get("/account", oauth2.LoginRequired, Account)
m.Get("/account-delete", oauth2.LoginRequired, AccountDelete)
m.Get("/account-redirect", oauth2.LoginRequired, AccountRedirect)
m.Get("/generate-pdf", oauth2.LoginRequired, GeneratePDF)
m.Get("/settings", oauth2.LoginRequired, Settings)
m.Get("/:hash", ShowHash)
// POST methods
m.Post("/cv-save", binding.Form(ProfileForm{}), oauth2.LoginRequired, Save)
m.Post("/cv-save-social", binding.Form(SocialNetworksForm{}), oauth2.LoginRequired, SaveSocial)
m.Post("/account-save", binding.Form(UsernameForm{}), oauth2.LoginRequired, AccountSave)
m.Post("/sections/new/:type", oauth2.LoginRequired, SectionsPost)
m.Post("/sections/:type/:section_id", oauth2.LoginRequired, SectionsPost)
m.Post("/sections/reorder", oauth2.LoginRequired, Reorder)
m.Post("/settings", binding.Form(SettingsForm{}), oauth2.LoginRequired, SettingsSave)
// Run server
// m.RunOnAddr(":8080")
m.Run()
}
示例7: BindTaskApi
func BindTaskApi(m *martini.ClassicMartini) {
m.Get("/admin/task/list", binding.Form(tasklistForm{}), adminErrorHandler, tasklistHandler)
m.Get("/admin/task/timeline", binding.Form(userTaskForm{}), adminErrorHandler, userTaskHandler)
//m.Get("/admin/task/timeline", binding.Form(taskTimelineForm{}), adminErrorHandler, taskTimelineHandler)
m.Post("/admin/task/auth", binding.Json(taskAuthForm{}), adminErrorHandler, taskAuthHandler)
m.Options("/admin/task/auth", optionsHandler)
m.Post("/admin/task/auth_list", binding.Json(taskAuthListForm{}), adminErrorHandler, taskAuthListHandler)
m.Options("/admin/task/auth_list", optionsHandler)
}
示例8: BindUeditorApi
func BindUeditorApi(m *martini.ClassicMartini) {
m.Get("/ueditor/controller",
binding.Form(ueditorForm{}),
ueditorHandler)
m.Post("/ueditor/controller",
binding.Form(ueditorForm{}),
ueditorHandler)
m.Options("/ueditor/controller",
binding.Form(ueditorForm{}),
ueditorHandler)
}
示例9: BindArticleApi
func BindArticleApi(m *martini.ClassicMartini) {
m.Post("/1/article/new",
binding.Json(newArticleForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
loadUserHandler,
checkLimitHandler,
newArticleHandler)
m.Post("/1/article/delete",
binding.Json(deleteArticleForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
loadUserHandler,
checkLimitHandler,
deleteArticleHandler)
m.Post("/1/article/thumb",
binding.Json(articleThumbForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
loadUserHandler,
checkLimitHandler,
articleThumbHandler)
m.Get("/1/article/is_thumbed",
binding.Form(articleIsThumbedForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
articleIsThumbedHandler)
m.Get("/1/article/timelines",
binding.Form(articleListForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
articleListHandler)
m.Get("/1/article/get",
binding.Form(articleInfoForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
articleInfoHandler)
m.Post("/1/article/comments",
binding.Json(articleCommentsForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
articleCommentsHandler)
m.Get("/1/aritcle/thumbList",
binding.Form(thumbersForm{}),
thumbersHandler)
m.Get("/1/article/news",
binding.Form(articleNewsForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
articleNewsHandler)
}
示例10: BindTaskApi
func BindTaskApi(m *martini.ClassicMartini) {
m.Get("/1/tasks/get",
binding.Form(getTaskForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
loadUserHandler,
getTaskHandler)
m.Get("/1/tasks/getList",
binding.Form(getTasksForm{}),
ErrorHandler,
checkTokenHandler,
loadUserHandler,
getTasksHandler)
m.Get("/1/tasks/getInfo",
binding.Form(getTaskInfoForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
//loadUserHandler,
getTaskInfoHandler)
m.Get("/1/tasks/result",
binding.Form(getTaskResultForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
//loadUserHandler,
getTaskResultHandler)
m.Post("/1/tasks/execute",
binding.Json(completeTaskForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
loadUserHandler,
checkLimitHandler,
completeTaskHandler)
m.Get("/1/tasks/referrals",
binding.Form(taskReferralForm{}),
ErrorHandler,
checkTokenHandler,
loadUserHandler,
taskReferralsHandler)
m.Post("/1/tasks/share",
binding.Json(taskShareForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
loadUserHandler,
taskShareHandler)
m.Post("/1/tasks/shared",
binding.Json(taskSharedForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
loadUserHandler,
taskSharedHandler)
}
示例11: BindUserApi
func BindUserApi(m *martini.ClassicMartini) {
m.Post("/1/user/send_device_token",
binding.Json(sendDevForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
sendDevHandler)
m.Post("/1/user/set_push_enable",
binding.Json(setPushForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
setPushHandler)
m.Get("/1/user/is_push_enabled",
binding.Form(pushStatusForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
pushStatusHandler)
m.Post("/1/user/enableAttention",
binding.Json(relationshipForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
loadUserHandler,
checkLimitHandler,
followHandler)
m.Post("/1/user/enableDefriend",
binding.Json(relationshipForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
loadUserHandler,
checkLimitHandler,
blacklistHandler)
m.Get("/1/user/getAttentionFriendsList",
binding.Form(getFollowsForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
getFollowsHandler)
m.Get("/1/user/getAttentedMembersList",
binding.Form(getFollowsForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
getFollowersHandler)
m.Get("/1/user/getJoinedGroupsList",
binding.Form(getFollowsForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
getGroupsHandler)
m.Get("/1/user/getRelatedMembersList",
binding.Form(socialListForm{}),
ErrorHandler,
socialListHandler)
}
示例12: main
func main() {
server := martini.Classic()
config := InitConfig()
//添加中間件
server.Use(render.Renderer(render.Options{ //render中間件可以把對象方便的序列化為xml或者json
Directory: "./html",
Extensions: []string{".html"},
Charset: "UTF-8",
}))
server.Use(martini.Static("public")) //靜態文件服務
//添加路由
//第一個參數是url路徑,
//之後的參數是處理該路徑請求的處理函數,
//可以添加多個,依次調用
//方法名表示該路徑的HTTP方法,表示隻能用GET訪問該路徑。
server.Get("/", cookie.Bind(UserCookie{}), handleHome)
//Group是父路徑下添加子路徑,下麵url分別表示/sched/all, /sched/all, /sched/delete。
//在父路徑裏添加的處理函數在子路徑中都會運行,
//比如下麵的cookie.Bind(UserCookie{}),該方法返回值是一個函數,表示這個路徑以及所有的子路徑都綁定了一個cookie。
server.Group("/sched", func(r martini.Router) {
r.Post("/add", binding.Form(Sched{}), handleAddSched)
r.Get("/all", handleGetSched)
r.Post("/delete", handleDelSched)
}, cookie.Bind(UserCookie{}))
server.Group("/user", func(r martini.Router) {
r.Post("/login", binding.Form(UserLoginForm{}), LoginHandler)
r.Post("/logout")
r.Post("/register", binding.Form(UserRegisterForm{}), RegisterHandler)
r.Post("/checklogin", cookie.Bind(UserCookie{}), CheckLoginHandler)
r.Group("/bkimg", func(rr martini.Router) {
rr.Post("/upload", binding.MultipartForm(Bkimg{}), UploadBkimg)
rr.Get("/get", GetBkimg)
}, cookie.Bind(UserCookie{}))
})
//映射服務
logger := log.New(os.Stdout, "[martini] ", log.Llevel|log.Lshortfile|log.Lmodule)
//Map方法傳入的對象可以被傳入到處理函數的對應參數中。
server.Map(logger)
server.Map(config)
server.RunOnAddr(":" + config.Server.Port)
}
示例13: main
func main() {
m := martini.Classic()
m.Use(gzip.All())
// render html templates from templates directory
m.Use(render.Renderer(render.Options{
Layout: "layout",
}))
m.Use(DB())
m.Get("/", func(r render.Render, db *mgo.Database) {
data := map[string]interface{}{"quotes": GetAll(db)}
r.HTML(200, "list", data)
})
m.Post("/", binding.Form(Quote{}), func(r render.Render, db *mgo.Database, quote Quote) {
db.C("quotes").Insert(quote)
data := map[string]interface{}{"quotes": GetAll(db)}
r.HTML(200, "list", data)
})
m.Run()
}
示例14: BindSysApi
func BindSysApi(m *martini.ClassicMartini) {
m.Get("/1/sys/config",
binding.Form(getSysConfForm{}),
ErrorHandler,
checkTokenHandler,
getSysConfHandler)
m.Get("/m",
mobileRedirectHandler)
}
示例15: BindFileApi
func BindFileApi(m *martini.ClassicMartini) {
m.Post("/1/file/upload",
binding.Form(fileUploadForm{}),
//ErrorHandler,
//checkTokenHandler,
fileUploadHandler)
m.Post("/1/file/delete",
binding.Json(fileDeleteForm{}, (*Parameter)(nil)),
ErrorHandler,
checkTokenHandler,
fileDeleteHandler)
m.Get("/1/file/uptoken",
binding.Form(uptokenForm{}),
ErrorHandler,
checkTokenHandler,
getQiniuTokenHandler)
//m.Post("/1/file/upload", binding.MultipartForm(fileUploadForm2{}), ErrorHandler, fileUploadHandler2)
//m.Get(ImageDownloadV1Uri, binding.Form(imageDownloadForm{}), ErrorHandler, imageDownloadHandler)
}