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

[TT-1698] Work with subrouters inside processSpec #3486

Merged
merged 1 commit into from Mar 15, 2021
Merged

[TT-1698] Work with subrouters inside processSpec #3486

merged 1 commit into from Mar 15, 2021

Conversation

@furkansenharputlu
Copy link
Member

@furkansenharputlu furkansenharputlu commented Mar 10, 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 created this PR as draft, after merging graphql PR, I will update go.mod and this PR will be ready.

@buger
Copy link
Member

@buger buger commented Mar 14, 2021

I see playground tests failing.
Is it because you need to update to latest mod version of graphql-go-tools?
Also its PR was merged, lets update and remove draft state.

@furkansenharputlu
Copy link
Member Author

@furkansenharputlu furkansenharputlu commented Mar 14, 2021

👍

@@ -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)

This comment has been minimized.

@buger

buger Mar 14, 2021
Member

Is it equal to subrouter.Handle("/", chainObj.ThisHandler)?
And if not, what is the difference?

This comment has been minimized.

@furkansenharputlu

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.

@furkansenharputlu furkansenharputlu force-pushed the routers branch 4 times, most recently from ca00611 to d61ab2c Mar 14, 2021
@furkansenharputlu furkansenharputlu marked this pull request as ready for review Mar 14, 2021
@buger buger merged commit 8fc3b6c into master Mar 15, 2021
8 of 10 checks passed
8 of 10 checks passed
Analyze (go) Analyze (go)
Details
Imports
Details
int-image
Details
lint
Details
Fmt
Details
goreleaser
Details
aws-mktplace-byol
Details
continuous-integration/travis-ci/pr The Travis CI build failed
Details
continuous-integration/travis-ci/push The Travis CI build failed
Details
CodeQL No new or fixed alerts
Details
@buger buger deleted the routers branch Mar 15, 2021
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)
@tykbot
Copy link

@tykbot tykbot bot commented Mar 15, 2021

@buger Succesfully merged 8fc3b6cff78d148d598ff359c99e7c9f170dcd8a to release-3 branch.

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)
@tykbot
Copy link

@tykbot tykbot bot commented Mar 15, 2021

@buger Succesfully merged 8fc3b6cff78d148d598ff359c99e7c9f170dcd8a to release-3.2 branch.

@buger
Copy link
Member

@buger buger commented Mar 15, 2021

@furkansenharputlu some branches require manual merge

@furkansenharputlu
Copy link
Member Author

@furkansenharputlu furkansenharputlu commented Mar 15, 2021

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.
@furkansenharputlu
Copy link
Member Author

@furkansenharputlu furkansenharputlu commented Mar 15, 2021

merged manually to:

  • release-3.0.5
  • release-3-lts
  • release-3.1
@TykTechnologies TykTechnologies deleted a comment from tykbot bot Mar 15, 2021
@TykTechnologies TykTechnologies deleted a comment from tykbot bot Mar 15, 2021
@TykTechnologies TykTechnologies deleted a comment from tykbot bot Mar 15, 2021
@TykTechnologies TykTechnologies deleted a comment from tykbot bot Mar 15, 2021
@TykTechnologies TykTechnologies deleted a comment from tykbot bot Mar 15, 2021
@TykTechnologies TykTechnologies deleted a comment from tykbot bot Mar 15, 2021
@TykTechnologies TykTechnologies deleted a comment from tykbot bot Mar 15, 2021
@TykTechnologies TykTechnologies deleted a comment from tykbot bot Mar 15, 2021
@TykTechnologies TykTechnologies deleted a comment from buger Mar 15, 2021
@TykTechnologies TykTechnologies deleted a comment from tykbot bot Mar 15, 2021
@TykTechnologies TykTechnologies deleted a comment from tykbot bot Mar 15, 2021
@TykTechnologies TykTechnologies deleted a comment from buger Mar 15, 2021
@TykTechnologies TykTechnologies deleted a comment from tykbot bot Mar 15, 2021
@TykTechnologies TykTechnologies deleted a comment from buger Mar 15, 2021
@TykTechnologies TykTechnologies deleted a comment from buger Mar 15, 2021
tykbot bot 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.

(cherry picked from commit f0398ab)
tykbot bot 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.

(cherry picked from commit f0398ab)
tykbot bot 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.

(cherry picked from commit f0398ab)
tykbot bot 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.

(cherry picked from commit f0398ab)
tykbot bot 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.

(cherry picked from commit f0398ab)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants