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

[THREESCALE-3189] Add maintenance policy #1105

Merged
merged 7 commits into from
Aug 7, 2019
Merged

Conversation

davidor
Copy link
Contributor

@davidor davidor commented Aug 6, 2019

This PR adds a new simple policy that allows users to reject incoming requests with a specified status code and message. It's useful for maintenance periods or to temporarily block an API.

This continues the work started by @alanmoran in #561

I used his commits, converted the policy to a builtin one (it was an example), and polished a few things and added some tests.

@davidor davidor requested a review from a team as a code owner August 6, 2019 09:16
@davidor davidor force-pushed the add-maintenance-policy branch from d2d309d to f0cb126 Compare August 6, 2019 09:32

if configuration then
policy.status_code = tonumber(configuration.status) or policy.status_code
policy.message = configuration.message or policy.message
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be useful to also set some header in case this is active. So you can have the payload as JSON for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean by setting a header here.
Do you mean returning JSON or plain text according to the value of the Accept header of the request?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean setting also Content-Type header when the policy is active. JSON payload is incorrect without proper Content-Type. And using two policies to activate mantenance mode would be weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

bcee0a9

@davidor davidor merged commit 8dba202 into master Aug 7, 2019
@davidor davidor deleted the add-maintenance-policy branch August 7, 2019 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants