本文整理汇总了Golang中github.com/martini-contrib/binding.Form函数的典型用法代码示例。如果您正苦于以下问题:Golang Form函数的具体用法?Golang Form怎么用?Golang Form使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Form函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
开发者ID:shevilangle,项目名称:sports,代码行数:7,代码来源:article.go
示例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,
)
}
开发者ID:shevilangle,项目名称:sports,代码行数:35,代码来源:record.go
示例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()
}
开发者ID:cwen-coder,项目名称:youth,代码行数:25,代码来源:youth.go
示例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()
}
开发者ID:mehulsbhatt,项目名称:bankOfHome,代码行数:30,代码来源:bank.go
示例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)
}
开发者ID:shevilangle,项目名称:sports,代码行数:30,代码来源:wallet.go
示例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()
}
开发者ID:tpiha,项目名称:barecv,代码行数:59,代码来源:main.go
示例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)
}
开发者ID:shevilangle,项目名称:sports,代码行数:9,代码来源:task.go
示例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)
}
开发者ID:shevilangle,项目名称:sports,代码行数:11,代码来源:ueditor.go
示例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)
}
开发者ID:shevilangle,项目名称:sports,代码行数:51,代码来源:article.go
示例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)
}
开发者ID:shevilangle,项目名称:sports,代码行数:51,代码来源:task.go
示例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)
}
开发者ID:shevilangle,项目名称:sports,代码行数:50,代码来源:user.go
示例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)
}
开发者ID:Felamande,项目名称:hmserver,代码行数:50,代码来源:servermain.go
示例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()
}
开发者ID:aeyoll,项目名称:go-quotes,代码行数:25,代码来源:server.go
示例14: BindSysApi
func BindSysApi(m *martini.ClassicMartini) {
m.Get("/1/sys/config",
binding.Form(getSysConfForm{}),
ErrorHandler,
checkTokenHandler,
getSysConfHandler)
m.Get("/m",
mobileRedirectHandler)
}
开发者ID:shevilangle,项目名称:sports,代码行数:9,代码来源:sys.go
示例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)
}
开发者ID:shevilangle,项目名称:sports,代码行数:19,代码来源:file.go
示例16: InitRoutes
func InitRoutes(m *martini.ClassicMartini) {
m.Get("/", ListBlogs)
m.Get("/new", NewBlog)
m.Post("/new", binding.Form(models.Post{}), CreateBlog)
m.Get("/post/:id", ShowBlog)
m.NotFound(func(r render.Render) {
fmt.Println("....................................................")
r.HTML(404, "status/404", "")
})
}
开发者ID:jijeshmohan,项目名称:martini-spike,代码行数:11,代码来源:routes.go
示例17: UploadHandlers
//martini Handler
func UploadHandlers() []martini.Handler {
var upload = func(fileData FileData, data UploadData, w http.ResponseWriter) {
retJsonp := &UploadRetJsonp{MessengerJs: MessengerJs, UpTime: data.UpTime}
if strings.ToUpper(data.Dir) != "IMAGE" {
retJsonp.Err(w, "dir wrong:"+data.Dir)
return
}
imgFile, err := fileData.ImgFile.Open()
if err != nil {
retJsonp.Err(w, "ImgFile:"+err.Error())
return
}
//取得bucket
bucket, err := bucketdb.FindByName(data.Bucket)
if err != nil {
retJsonp.Err(w, "FindByName:"+err.Error())
return
}
if bucket.Uptoken == "" {
if err := bucket.NewUptoken(); err != nil {
retJsonp.Err(w, "NewUptoken:"+err.Error())
return
}
if err := bucket.Save(); err != nil {
retJsonp.Err(w, "Save:"+err.Error())
return
}
}
//上传内容到Qiniu
var ret qio.PutRet
// ret 变量用于存取返回的信息,详情见 qio.PutRet
// uptoken 为业务服务器端生成的上传口令
// key:imgName 为文件存储的标识
// r:imgFile 为io.Reader类型,用于从其读取数据
// extra 为上传文件的额外信息,可为空, 详情见 qio.PutExtra, 可选
err = qio.Put(nil, &ret, bucket.Uptoken, fileData.ImgName(), imgFile, nil)
if err != nil {
bucket.LogErr()
retJsonp.Err(w, "Put:"+err.Error())
return
}
//上传成功,返回给KindEditor
//w.Header().Set("Content-type", "application/json")
retJsonp.Respose(w, bucket.ImgUrl(ret.Key))
}
return []martini.Handler{binding.MultipartForm(FileData{}), binding.Form(UploadData{}), upload}
}
开发者ID:empirefox,项目名称:iniu-old,代码行数:54,代码来源:upload.go
示例18: configureRoutes
func configureRoutes(router martini.Router) {
// 404 handler
router.NotFound(func(render render.Render) {
render.Redirect("/404")
})
// Common Routes
router.Get("/", controllers.Home)
router.Get("/404", controllers.NotFound)
router.Get("/500", controllers.InternalServerError)
// Player Routes
router.Get("/players", controllers.GetPlayers)
router.Get("/player/new", controllers.GetNewPlayer)
router.Post("/player/new", binding.Form(controllers.PlayerData{}), controllers.CreatePlayer)
router.Get("/player/:id", controllers.GetPlayerById)
router.Post("/player/:id", binding.Form(controllers.PlayerData{}), binding.Form(controllers.OriginalData{}), controllers.ModifyPlayer)
// Game Routes
router.Get("/games", controllers.GetGames)
router.Get("/game/new", controllers.GetNewGame)
router.Post("/game/new", binding.Form(controllers.GameData{}), controllers.CreateGame)
router.Get("/game/:id", controllers.GetGameById)
}
开发者ID:BrettKercher,项目名称:Vorpal,代码行数:24,代码来源:main.go
示例19: InitRoutes
func InitRoutes(m *martini.ClassicMartini) {
m.Group("/devices", func(r martini.Router) {
r.Get("", ListDevices)
r.Post("", binding.Form(models.Device{}), CreateDevice)
r.Get("/new", NewDevice)
// r.Get("/:id", ShowDevice)
})
m.Get("/sock", Socket)
m.Get("/node", Node)
m.NotFound(func(r render.Render) {
r.HTML(404, "status/404", "")
})
}
开发者ID:jijeshmohan,项目名称:mtgrid,代码行数:15,代码来源:routes.go
示例20: main
func main() {
// Create martini
m := martini.Classic()
// Setup database connection
db := setupDb(m)
// Setup email configuration
emailConfig := setupEmail(m)
// Setup middleware
m.Use(martini.Static("public"))
m.Use(render.Renderer())
m.Use(api.AuthenticateUser(db))
// Create controllers
pages := controllers.PagesController{}
apiUsers := api.NewUsers(db, emailConfig)
apiSchedules := api.NewSchedules(db)
apiSyncs := api.NewSyncs(db)
// Routing
m.Get("/", pages.Home)
m.Group("/api/users", func(r martini.Router) {
r.Post("/login", apiUsers.Login)
r.Post("/register", binding.Form(models.RegisterUser{}), apiUsers.Register)
r.Post("/register_gcm", api.NeedsAuth(true), apiUsers.RegisterGcm)
r.Post("/verify", api.NeedsAuth(false), apiUsers.Verify)
r.Get("/search", api.NeedsAuth(true), apiUsers.Search)
})
m.Group("/api/schedules", func(r martini.Router) {
r.Post("/add", api.NeedsAuth(true), apiSchedules.Add)
})
m.Group("/api/syncs", func(r martini.Router) {
r.Get("/index", api.NeedsAuth(true), apiSyncs.Index)
r.Post("/create", api.NeedsAuth(true), apiSyncs.Create)
})
// Start server
m.Run()
}
开发者ID:GEDUtech,项目名称:ridesyncer_server,代码行数:44,代码来源:server.go
注:本文中的github.com/martini-contrib/binding.Form函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论