You can control when transformations occur by providing procs to the following options:
exclude_params: A proc that receives the env and returns true if inbound parameter transformation should be skipped.exclude_response: A proc that receives the env and returns true if outbound response transformation should be skipped.content_type_check: A proc that receives the content_type string and returns true if transformation should proceed.
Example: Excluding Rails internal routes from transformation:
rails_routes = -> (env) { env['PATH_INFO'].match(/^/rails/) }
config.middleware.use OliveBranch::Middleware, inflection: "camel", exclude_params: rails_routes, exclude_response: rails_routes
# Exclude specific URL patterns for params
config.middleware.use OliveBranch::Middleware, exclude_params: -> (env) { env['PATH_INFO'].match('/\/do_not_transform/') }
# Exclude specific URL patterns for responses
config.middleware.use OliveBranch::Middleware, exclude_response: -> (env) { env['PATH_INFO'].match('/\/do_not_transform/') }
# Custom content type check
config.middleware.use OliveBranch::Middleware, content_type_check: -> (content_type) { content_type == "my/content-type" }