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

context: inherits context cancelation and deadline from http.Request context for Go>=1.7 #1690

Merged
merged 3 commits into from Dec 13, 2018

Conversation

rbeuque74
Copy link
Contributor

*gin.Context implements standard context.Context methods, but always
returns data as context is still valid. Since Go 1.7, http.Request now
contains a context.Context object, which can be controlled by the
http.Server to indicates that the context is now closed, and persue of
request should be canceled.

This implements the propagation of http.Request context methods inside
gin.Context to have HTTP context cancelation information at gin.Context
level.

This is retro-compatible for Golang 1.6, and have no effect if http.Request have no context (as http.Request always provide context.Background is ctx is nil)

@rbeuque74
Copy link
Contributor Author

Build failing because of Travis timeout, if one of the maintainer can restart the build :)
Thanks!

context_17_test.go Outdated Show resolved Hide resolved
…context for Go>=1.7

*gin.Context implements standard context.Context methods, but always
returns data as context is still valid. Since Go 1.7, http.Request now
contains a context.Context object, which can be controlled by the
http.Server to indicates that the context is now closed, and persue of
request should be canceled.

This implements the propagation of http.Request context methods inside
gin.Context to have HTTP context cancelation information at gin.Context
level.

Signed-off-by: Romain Beuque <romain.beuque@corp.ovh.com>
@codecov
Copy link

codecov bot commented Dec 11, 2018

Codecov Report

Merging #1690 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1690      +/-   ##
=========================================
+ Coverage    99.4%   99.4%   +<.01%     
=========================================
  Files          41      42       +1     
  Lines        2023    2029       +6     
=========================================
+ Hits         2011    2017       +6     
  Misses          9       9              
  Partials        3       3
Impacted Files Coverage Δ
context.go 99.5% <ø> (-0.01%) ⬇️
context_pre17.go 100% <100%> (ø)
context_17.go 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 59695e7...2c4151f. Read the comment docs.

Copy link
Member

@thinkerou thinkerou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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

Successfully merging this pull request may close these issues.

None yet

2 participants