Skip to content
This repository has been archived by the owner on Dec 23, 2023. It is now read-only.

Context enhancement #27

Merged
merged 38 commits into from Apr 4, 2020
Merged

Context enhancement #27

merged 38 commits into from Apr 4, 2020

Conversation

razonyang
Copy link
Member

@razonyang razonyang commented Apr 2, 2020

  • Context.SetCookie: already done since v1.6
  • Context.Cookies and Context.Cookie
  • Context.Emit, Context.Blob
  • Context.JSON, Context.JSONBlob
  • Context.JSONP, Context.JSONPCallback, Context.JSONPBlob, Context.JSONPCallbackBlob
  • Context.XML, Context.XMLBlob
  • Context.String
  • Context.HTML, Context.HTMLBlob
  • Context.FormValue
  • Context.PostFormValue
  • Context.QueryString, Context.QueryParams and Context.QueryParam
  • Context.Render: renders a template. Renderer implementation:
  • Context.RouteURL: generates the URL of naming route.

@razonyang razonyang changed the title Add Context.JSON Fix #26: Context enhancement Apr 2, 2020
@razonyang razonyang linked an issue Apr 2, 2020 that may be closed by this pull request
@razonyang razonyang self-assigned this Apr 2, 2020
@razonyang razonyang added this to the v1.9 milestone Apr 2, 2020
@razonyang razonyang changed the title Fix #26: Context enhancement Context enhancement Apr 2, 2020
@razonyang razonyang marked this pull request as ready for review April 3, 2020 03:18
@beikege
Copy link
Contributor

beikege commented Apr 3, 2020

和新增的 JSON HTML ... 方法风格统一,状态码在前.

当前:

func (ctx *Context) Redirect(url string, code int) {

ctx.Redirect("https://www.google.com/", 302)
return nil

修改后:

func (ctx *Context) Redirect(code int, url string) error {
return ctx.Redirect(302, "https://www.google.com/")

能少写一行.

@razonyang
Copy link
Member Author

我觉得现有的接口尽量保持原样,不作改动,以避免打破向后兼容性。另外 Redirect 使用频率应该很低,对编码影响不大。

context.go Outdated Show resolved Hide resolved
@razonyang
Copy link
Member Author

@beikege 基本完成了,可以 review 或补充一下。

另外已经添加了 Jet Renderer 的实现,至于其他模板引擎,由于没有太多的了解和使用经验,就不一一实现了。

context.go Outdated Show resolved Hide resolved
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

建议添加一些常用的快捷输出方法.
2 participants