-
Notifications
You must be signed in to change notification settings - Fork 503
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
Expose route for context #1128
Expose route for context #1128
Conversation
Codecov ReportAttention: ❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
... and 2 files with indirect coverage changes 📢 Thoughts on this report? Let us know!. |
pkg/context/context.go
Outdated
@@ -92,6 +94,16 @@ func New(span *tracing.Span) *Context { | |||
return ctx | |||
} | |||
|
|||
// SetRoute sets the route. | |||
func (ctx *Context) SetRoute(route routers.Route) { |
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.
this context contains general protocol for multiple protocols. Such as HTTP, GRPC... Maybe update this name to SetHTTPRoute
, GetHTTPRoute
or make the route interface{} SetRoute(protocols.Route)
?
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.
Updated
72332c6
to
00ff123
Compare
@@ -25,6 +25,7 @@ import ( | |||
|
|||
"github.com/megaease/easegress/v2/pkg/context" | |||
"github.com/megaease/easegress/v2/pkg/filters" | |||
httprouters "github.com/megaease/easegress/v2/pkg/object/httpserver/routers" |
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.
Looks good to me. Just a little advice. How about add a type alias in github.com/megaease/easegress/v2/pkg/protocols/httpprot
say:
var Route = github.com/megaease/easegress/v2/pkg/object/httpserver/routers.Route
then
prefix := route.(httpprot.Route).GetPathPrefix()
The code produce exactly same result. But for future developers, it may a little bit easier for them to find right interface?
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.
That will cause an import cycle.
Have tried to design a universal exposed route type system which is complicated and unnecessary, so I turned to the minimum way to implement the current requirement.
Will try to update Gateway API to v1.0.0(GA), there's tons of broken dependencies to fix...