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

Support skipping certain path(s) with config skip_paths #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

choznerol
Copy link

@choznerol choznerol commented Nov 19, 2020

Thanks for creating this gem!

This PR support skipping certain paths with a new configuration option skip_paths.

skip_paths supports both String and Regexp, and will be matched against env['PATH_INFO'].

Example usage:

Rails.application.config.json_key_transformer_middleware.skip_paths = [/^\/admin/, '/graphql']

# Will not transform neither `GET /admin/foo?bar_id=1` nor `POST /graphql`

Some thoughts:

  1. Perhaps skip_paths is a better name? I updated excluded_paths to skip_paths
  2. I also considered accepting a proc to achieve the same goal (e.g. should_skip = ->(env) { env['PATH_INFO'].match?('/foobar') }) but thinking this could be a bit confusing, and users may not need such flexibility. If providing another advanced config should_skip sounds good I can send another PR for that.

@choznerol choznerol force-pushed the feat/excluded_paths branch 3 times, most recently from 55bcb38 to 3669a33 Compare November 20, 2020 06:05
@choznerol choznerol changed the title Support skipping certain path(s) with config excluded_paths Support skipping certain path(s) with config skip_paths Nov 20, 2020
choznerol added a commit to choznerol/json_key_transformer_middleware that referenced this pull request Dec 10, 2020
…pe-is-not-application-json

Check Content-Type ~= application/json by default
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.

1 participant