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

feat: Add sample for blocking a request with particular header. #8

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

nkllkc
Copy link

@nkllkc nkllkc commented May 30, 2023

Add a sample that checks the client referer header for a bad value, serve a synthetic 404 block with a basic html response (error not found).

  • [ X] Tests pass
  • [X ] Appropriate changes to documentation are included in the PR

@nkllkc nkllkc requested review from a team and upeeth as code owners May 30, 2023 00:48
@snippet-bot
Copy link

snippet-bot bot commented May 30, 2023

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@nkllkc
Copy link
Author

nkllkc commented May 30, 2023

/assign @wsh

@nkllkc nkllkc changed the title Add sample for blocking a request with particular header. feat: Add sample for blocking a request with particular header. May 30, 2023
Copy link
Contributor

@leonm1 leonm1 left a comment

Choose a reason for hiding this comment

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

Approved pending confirmation from @mpwarres that StopAllIterationAndWatermark is the desired return value for a plugin that calls sendLocalResponse.

Thanks for sending this PR!

samples/block_requests/plugin.cc Show resolved Hide resolved
samples/block_requests/test.cc Show resolved Hide resolved
Copy link
Collaborator

@martijneken martijneken left a comment

Choose a reason for hiding this comment

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

Thanks for contributing! A few nits but otherwise LGTM

// limitations under the License.

#include "proxy_wasm_intrinsics.h"
#include <regex>
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: unused

// See the License for the specific language governing permissions and
// limitations under the License.

// [START serviceextensions_example_block_request]
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: remove _example fragment from name, here and below

// See the License for the specific language governing permissions and
// limitations under the License.

#include "proxy_wasm_intrinsics.h"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Repeat [START] and [END] tags in the C++ sample

@@ -30,6 +30,8 @@ plugin. Extend them to fit your particular use case.
* [Add HTTP request & response headers](samples/add_header): Add a header on
both the client request and server response paths. Also check for existing
headers.
* [Block Request with Particular Header Value](samples/block_request): Deny
a request whenever it contains a paritcular header set to certain value.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: s/paritcular/particular

@msampathkumar
Copy link
Member

@nkllkc - Just a health check. This PR seems to have no recent updates. PTAL

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.

5 participants