-
Notifications
You must be signed in to change notification settings - Fork 664
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
[CHANGED] Use interface instead of struct for micro.Request #1174
Conversation
micro/request.go
Outdated
} | ||
|
||
// RequestHandler is a function used as a Handler for a service. | ||
RequestHandler func(*Request) | ||
RequestHandler func(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.
Handler could be interface based here too a la http.Handler, that would make it convenient to pass around types that can handle requests, think something like this:
// micro.RequestHandler
type RequestHandler func(Request)
func (fn RequestHandler) Handle(req Request) {
fn(req)
}
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.
Very good idea, thanks!
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.
added
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.
LGTM 👍
micro.Request
to an interface