本文整理汇总了Golang中github.com/speedland/wcg.Request.Form方法的典型用法代码示例。如果您正苦于以下问题:Golang Request.Form方法的具体用法?Golang Request.Form怎么用?Golang Request.Form使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/speedland/wcg.Request
的用法示例。
在下文中一共展示了Request.Form方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: updateAttributesFromForm
func updateAttributesFromForm(res *wcg.Response, req *wcg.Request, e *event.Event) error {
var err error
if err = eventFormValidator.Eval(req.HttpRequest().PostForm); err != nil {
return err
}
e.Title = req.Form("title")
e.Link = req.Form("link")
e.ImageLink = req.Form("image_link")
e.YAKeyword = req.Form("ya_keyword")
e.EventType = event.ParseEventType(req.Form("event_type"))
return nil
}
示例2: updatePostHandler
func updatePostHandler(res *wcg.Response, req *wcg.Request) {
blog, _, err := fetchBlogForUpdate(res, req, false)
if err != nil {
return
}
post, err := fetchPostForUpdate(req, res, blog)
if err != nil {
return
}
post.Title = req.Form("title")
post.Content = req.Form("content")
post.IsDraft = req.Form("is_draft") == "true"
post.IsNew = false
post.PostDate, err = time.Parse(wcg.FormDateFormat, req.Form("post_date"))
post.Tags = strings.Split(req.Form("tags"), ",")
for i, v := range post.Tags {
post.Tags[i] = strings.TrimSpace(v)
}
if err != nil {
res.WriteHeader(400)
res.WriteString("Invalid date format.")
res.End()
}
driver := models.NewPostDriver(gae.NewContext(req), req.Logger)
if AppConfig.GithubMarkdown {
driver.HttpClient = gae.NewHttpClient(req)
}
err = driver.SavePost(post)
if err != nil {
if supports.IsValidationError(err) {
res.WriteJsonWithStatus(400, nil, err)
} else {
res.RenderInternalError(err.Error())
}
return
}
req.Logger.Info("A post is created at %s.", post.Id)
res.WriteJsonWithStatus(200, nil, ok)
}
示例3: updateBlogHandler
func updateBlogHandler(res *wcg.Response, req *wcg.Request) {
driver := models.NewBlogDriver(gae.NewContext(req), req.Logger)
err := driver.UpdateBlog(
req.Param("blog_id"),
req.Form("title"),
req.Form("description"),
req.User.Id(),
)
if err != nil {
if supports.IsValidationError(err) {
res.WriteJsonWithStatus(400, nil, err)
} else if err == models.ErrBlogNotOwned {
res.WriteJsonWithStatus(403, nil, no_permission)
} else if err == models.ErrBlogNotFound {
res.WriteJsonWithStatus(404, nil, not_found)
} else {
res.RenderInternalError(err.Error())
}
return
}
res.WriteJsonWithStatus(200, nil, ok)
}
示例4: createBlogHandler
func createBlogHandler(res *wcg.Response, req *wcg.Request) {
driver := models.NewBlogDriver(gae.NewContext(req), req.Logger)
blog, err := driver.CreateBlog(
req.Form("path"),
req.Form("title"),
req.Form("description"),
req.User.Id(),
)
if err != nil {
if err == models.ErrBlogAlreadyExists {
res.WriteJsonWithStatus(409, nil, already_taken)
} else if supports.IsValidationError(err) {
res.WriteJsonWithStatus(400, nil, err)
} else {
res.RenderInternalError(err.Error())
}
return
}
res.WriteJsonWithStatus(201, map[string]string{
"location": wcg.AbsoluteUrl(req, "/"+blog.Id),
}, ok)
}
示例5: updateShowAttributes
func updateShowAttributes(req *wcg.Request, s *event.Show) *event.Show {
s.OpenAt, _ = util.ParseDateTime(req.Form("open_at"))
s.StartAt, _ = util.ParseDateTime(req.Form("start_at"))
s.Latitude, _ = strconv.ParseFloat(req.Form("latitude"), 64)
s.Longitude, _ = strconv.ParseFloat(req.Form("longitude"), 64)
s.VenueId = req.Form("venue_id")
s.VenueName = req.Form("venue_name")
s.PiaLink = req.Form("pia_link")
s.YAKeyword = req.Form("ya_keyword")
return s
}
示例6: updateAttributesFromForm
func updateAttributesFromForm(res *wcg.Response, req *wcg.Request, p *blog.Post) error {
var err error
if err = postFormValidator.Eval(req.HttpRequest().PostForm); err != nil {
return err
}
p.Title = req.Form("title")
p.Content = req.Form("content")
p.Tags = blog.ParseTagString(req.Form("tags"))
p.IsDraft = req.Form("is_draft") == "true"
p.IsHidden = req.Form("is_hidden") == "true"
p.PublishAt, err = wcg.ParseDateTime(req.Form("publish_at"))
return nil
}