当前位置: 首页>>代码示例>>Golang>>正文


Golang Request.Form方法代码示例

本文整理汇总了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
}
开发者ID:speedland,项目名称:apps,代码行数:12,代码来源:api_event.go

示例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)
}
开发者ID:speedland,项目名称:rakugaki,代码行数:41,代码来源:posts.go

示例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)
}
开发者ID:speedland,项目名称:rakugaki,代码行数:22,代码来源:blogs.go

示例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)
}
开发者ID:speedland,项目名称:rakugaki,代码行数:22,代码来源:blogs.go

示例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
}
开发者ID:speedland,项目名称:apps,代码行数:11,代码来源:api_event_show.go

示例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
}
开发者ID:speedland,项目名称:apps,代码行数:13,代码来源:api_post.go


注:本文中的github.com/speedland/wcg.Request.Form方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。