-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ARP - lower camel responses - 1]
set_key_transform :camel_lower
(#…
…20621) * [ARP] `set_key_transform :camel_lower` * lint fixes * [ARP - lower camel responses - 2] camel case POA form persistence (#20622) * [ARP] camel case POA form persistence * lint fixes * [ARP - lower camel responses - 3] handle camel params in ARP IPF controller (#20623) * [ARP] handle camel params in ARP IPF controller * [ARP - lower camel responses - 4] camel response in ARP users controller (#20624) * [ARP] camel response in ARP users controller * [ARP - lower camel responses - 5] bypass olive branch (#20625) * [ARP] bypass olive branch * lint fixes
- Loading branch information
Showing
14 changed files
with
293 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
modules/accredited_representative_portal/config/initializers/bypass_olive_branch.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# frozen_string_literal: true | ||
|
||
module AccreditedRepresentativePortal | ||
## | ||
# `olive_branch` transforms (a) request and (b) response payloads. | ||
# | ||
# (a) It deeply transforms request and query param keys. | ||
# At times it is convenient for params to act as snake-cased setters at a Ruby | ||
# interface, but not always. Form resources are a possible example where not. | ||
# | ||
# For now, let's wait to encounter the cases where we really want this | ||
# convenience. If we do encounter some, we may discover that we want a more | ||
# explicit and collocated way to opt in. | ||
# | ||
# (b) It reloads the response from JSON, deeply transforms keys, and dumps | ||
# back to JSON. | ||
# This is superfluous because our serialization layer `jsonapi-serializer` | ||
# already has a configuration option for key casing. This realizes our desired | ||
# casing the one and only time it is visiting an object during serialization. | ||
# | ||
module BypassOliveBranch | ||
def call(env) | ||
exclude_arp_route?(env) ? @app.call(env) : super | ||
end | ||
|
||
private | ||
|
||
ARP_PATH_INFO_PREFIX = '/accredited_representative_portal' | ||
|
||
def exclude_arp_route?(env) | ||
env['PATH_INFO'].to_s.start_with?(ARP_PATH_INFO_PREFIX) | ||
end | ||
end | ||
end | ||
|
||
module OliveBranch | ||
class Middleware | ||
prepend AccreditedRepresentativePortal::BypassOliveBranch | ||
end | ||
end |
Oops, something went wrong.