Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about context #8

Open
ics091 opened this issue Nov 19, 2022 · 1 comment
Open

about context #8

ics091 opened this issue Nov 19, 2022 · 1 comment

Comments

@ics091
Copy link

ics091 commented Nov 19, 2022

处理请求的时候好像没使用go原生的context,为啥?用这个HttpContext是因为能带更多信息?

  // HTTPContext context of a api call
  type HTTPContext struct {
	  Request  *http.Request
	  Response http.ResponseWriter
	  buf      *bytes.Buffer
	  header   []httpHeader
	  user     *user.TypeDB
	  userGot  bool
  }
@OhYee
Copy link
Owner

OhYee commented Nov 20, 2022

处理请求的时候好像没使用go原生的context,为啥?用这个HttpContext是因为能带更多信息?

  // HTTPContext context of a api call
  type HTTPContext struct {
	  Request  *http.Request
	  Response http.ResponseWriter
	  buf      *bytes.Buffer
	  header   []httpHeader
	  user     *user.TypeDB
	  userGot  bool
  }

可以用,不过本身context类型不太友好,需要再封装一层。
这里做成这样方便补全使用,如果需要用到 withCancel 等 context 特性也可以比较容易直接加进去

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants