-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
feature: add ConvertRequest func #1024
feature: add ConvertRequest func #1024
Conversation
To easy method to convert ctx.RequestCtx to http.Request
fasthttpadaptor/request.go
Outdated
// ConvertRequest convert a fasthttp.Request to http.Request | ||
// setURI is optionally because your use in client mode | ||
func ConvertRequest(ctx *fasthttp.RequestCtx, setURI bool) (*http.Request, error) { | ||
var r http.Request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, the http.Request
could be part of the ConvertRequest()
parameters to can use a sync.Pool
if it's needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somethig like this:
func ConvertRequest(ctx *fasthttp.RequestCtx, setURI bool, req *http.Request) error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I agree with this. http.Request
contains unexported fields. It's not trivial to reuse an http.Request
with sync.Pool
and the standard library gives no guarantee that this might break in the future.
But I guess it's up to the user to make this work properly.
@savsgio @erikdubbelboer Thanks for review! Can you revise again? |
LGTM! |
To easy method to convert ctx.RequestCtx to http.Request