[TT-1698] Work with subrouters inside processSpec #3486
Merged
Conversation
|
I see playground tests failing. |
|
|
| @@ -679,7 +680,7 @@ func loadHTTPService(spec *APISpec, apisByListen map[string]int, gs *generalStor | |||
| router.Handle(chainObj.RateLimitPath, chainObj.RateLimitChain) | |||
| } | |||
|
|
|||
| router.Handle(chainObj.ListenOn, chainObj.ThisHandler) | |||
| subrouter.NewRoute().Handler(chainObj.ThisHandler) | |||
buger
Mar 14, 2021
Member
Is it equal to subrouter.Handle("/", chainObj.ThisHandler)?
And if not, what is the difference?
furkansenharputlu
Mar 14, 2021
Author
Member
It is not equal. The difference is / only matches /. However, the NewRoute() matches anything.
With / you will get Not Found for a simple httpbin get operation.
ca00611
to
d61ab2c
tykbot bot
pushed a commit
that referenced
this pull request
Mar 15, 2021
The master router is passed to the `processSpec` and while adding handlers to it always needs to put listen path in front. I realized that it is more than a redundancy. For example, if I want to add CORS middleware to subrouter, it wasn't matching with the listen path because they were living in the master router. This PR gets subrouter first and passes it to the `processSpec` function. - I saw that there is a problem in graphql playground. So I created a PR to that repo as well: TykTechnologies/graphql-go-tools#100 I created this PR as draft, after merging graphql PR, I will update `go.mod` and this PR will be ready. (cherry picked from commit 8fc3b6c)
|
@buger Succesfully merged |
tykbot bot
pushed a commit
that referenced
this pull request
Mar 15, 2021
The master router is passed to the `processSpec` and while adding handlers to it always needs to put listen path in front. I realized that it is more than a redundancy. For example, if I want to add CORS middleware to subrouter, it wasn't matching with the listen path because they were living in the master router. This PR gets subrouter first and passes it to the `processSpec` function. - I saw that there is a problem in graphql playground. So I created a PR to that repo as well: TykTechnologies/graphql-go-tools#100 I created this PR as draft, after merging graphql PR, I will update `go.mod` and this PR will be ready. (cherry picked from commit 8fc3b6c)
|
@buger Succesfully merged |
|
@furkansenharputlu some branches require manual merge |
|
I will merge manually. Thanks! |
buger
pushed a commit
that referenced
this pull request
Mar 15, 2021
In the PR: #3486, there is route changes including `/tyk/rate-limits/`. However, this endpoint doesn't have any test. This PR adds a test for it to make sure that the new PR doesn't break it.
furkansenharputlu
added a commit
that referenced
this pull request
Mar 15, 2021
The master router is passed to the `processSpec` and while adding handlers to it always needs to put listen path in front. I realized that it is more than a redundancy. For example, if I want to add CORS middleware to subrouter, it wasn't matching with the listen path because they were living in the master router. This PR gets subrouter first and passes it to the `processSpec` function. - I saw that there is a problem in graphql playground. So I created a PR to that repo as well: TykTechnologies/graphql-go-tools#100 I created this PR as draft, after merging graphql PR, I will update `go.mod` and this PR will be ready.
furkansenharputlu
added a commit
that referenced
this pull request
Mar 15, 2021
The master router is passed to the `processSpec` and while adding handlers to it always needs to put listen path in front. I realized that it is more than a redundancy. For example, if I want to add CORS middleware to subrouter, it wasn't matching with the listen path because they were living in the master router. This PR gets subrouter first and passes it to the `processSpec` function. - I saw that there is a problem in graphql playground. So I created a PR to that repo as well: TykTechnologies/graphql-go-tools#100 I created this PR as draft, after merging graphql PR, I will update `go.mod` and this PR will be ready.
furkansenharputlu
added a commit
that referenced
this pull request
Mar 15, 2021
The master router is passed to the `processSpec` and while adding handlers to it always needs to put listen path in front. I realized that it is more than a redundancy. For example, if I want to add CORS middleware to subrouter, it wasn't matching with the listen path because they were living in the master router. This PR gets subrouter first and passes it to the `processSpec` function. - I saw that there is a problem in graphql playground. So I created a PR to that repo as well: TykTechnologies/graphql-go-tools#100 I created this PR as draft, after merging graphql PR, I will update `go.mod` and this PR will be ready.
|
merged manually to:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
The master router is passed to the
processSpecand while adding handlers to it always needs to put listen path in front. I realized that it is more than a redundancy. For example, if I want to add CORS middleware to subrouter, it wasn't matching with the listen path because they were living in the master router. This PR gets subrouter first and passes it to theprocessSpecfunction.I created this PR as draft, after merging graphql PR, I will update
go.modand this PR will be ready.