-
Notifications
You must be signed in to change notification settings - Fork 4.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
feat(plugin) Adding path prefix support in request transformer #1426
feat(plugin) Adding path prefix support in request transformer #1426
Conversation
(was based on the old master branch style instead of new next styles)
if (stringy.startswith(uri, value)) then | ||
uri = uri:sub(value:len() + 1) | ||
if (uri:substr(0, value:len()) == value) then | ||
uri = uri:substr(value:len() + 1) |
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.
shouldn't this be sub
instead of substr
? does this even work...
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.
Oops, typo. Good catch! Thanks! Updated in 99b3a63.
I think
|
@Tieske — I'm not completely following. What are the specific expectations you have in mind? Are you talking about upon API routing? or setting the plugin settings? |
@andyfleming apologies for not being clear. I meant the plugin settings. |
@Tieske No worries. Is there another file I can look at that has similar tests to use as a starting point? |
have a look at the existing request-tranformer api specs; https://github.com/Mashape/kong/blob/next/spec/03-plugins/13-request-transformer/02-api_spec.lua just extend that file with the new tests |
and this is the existing code for checking a path; https://github.com/Mashape/kong/blob/next/kong/dao/schemas/apis.lua#L76-L109 |
It looks like my use case is actually already covered by I'm going to close this. If someone else later wants to pursue this functionality, they are welcome to run with it. |
Summary
Allows for a path prefix to be prepended or removed.
So with the following configuration...
A request to
/example/page
would be transformed to/another/page
NOTE: I have not set up a full dev environment, so I have not actually tested these changes.
If someone could take a look, I think the changes are pretty straightforward.
Full changelog
Issues resolved
May address #724