From 70d8b5791eaa71647f61d40f7a2cbe911cab8e4d Mon Sep 17 00:00:00 2001 From: Boris Shatalov Date: Fri, 31 May 2024 02:57:54 +0600 Subject: [PATCH] [DEX-2295] improvement: rename "proxy_http_verb" to "proxy_http_method" --- CHANGELOG.md | 5 +++++ README.md | 5 ++--- lib/sbmt/strangler/action.rb | 3 ++- lib/sbmt/strangler/mixin.rb | 2 +- spec/internal/config/initializers/strangler.rb | 4 +--- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c23abe..f4c4ad7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [0.x.0] - 2024-05-xx + +### Changed +- rename "proxy_http_verb" to "proxy_http_method" + ## [0.6.0] - 2024-05-30 ### Added diff --git a/README.md b/README.md index f3c31f2..7f807be 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ To determine the proxy mode, you need to: controller.action("index") do |action| action.proxy_url = "http://example.com:8080/api/hello" - action.proxy_http_verb = :post + action.proxy_http_method = :post end end ``` @@ -58,7 +58,7 @@ Sbmt::Strangler.configure do |strangler| controller.action("index") do |action| action.proxy_url = "http://example.com:8080/api/hello" - action.proxy_http_verb = :post + action.proxy_http_method = :post # new implementation of legacy system business logic action.mirror = ->(rails_controller) do @@ -84,4 +84,3 @@ end To enable replacement mode, use the feature flag. Replacement mode uses mirror lambda for replacement logic. - diff --git a/lib/sbmt/strangler/action.rb b/lib/sbmt/strangler/action.rb index 903b891..6d443a4 100644 --- a/lib/sbmt/strangler/action.rb +++ b/lib/sbmt/strangler/action.rb @@ -6,7 +6,8 @@ class Action extend Sbmt::Strangler::Configurable option :params_tracking_allowlist, :headers_allowlist, :flipper_actor, default_from: :controller - option :proxy_url, :proxy_http_verb + option :proxy_url + option :proxy_http_method, default: :get option :mirror, default: ->(_rails_controller) {} option :compare, default: ->(_origin_result, _mirror_result) { false } diff --git a/lib/sbmt/strangler/mixin.rb b/lib/sbmt/strangler/mixin.rb index 3bb11bd..74af48b 100644 --- a/lib/sbmt/strangler/mixin.rb +++ b/lib/sbmt/strangler/mixin.rb @@ -26,7 +26,7 @@ def allowed_headers def http_request(payload) http_client.call( proxy_url, - strangler_action.proxy_http_verb, + strangler_action.proxy_http_method, payload: payload, headers: allowed_headers ) diff --git a/spec/internal/config/initializers/strangler.rb b/spec/internal/config/initializers/strangler.rb index 1e2d078..efe4cae 100644 --- a/spec/internal/config/initializers/strangler.rb +++ b/spec/internal/config/initializers/strangler.rb @@ -10,7 +10,7 @@ module Orders controller.action("index") do |action| action.proxy_url = "http://example.com:8080/api/stores" - action.proxy_http_verb = :post + action.proxy_http_method = :post action.mirror = ->(_rails_controller) do {json: '["mirror_result"]', status: :ok} end @@ -22,7 +22,6 @@ module Orders controller.action("show") do |action| action.proxy_url = lambda { |params, _headers| "http://example.com:8080/api/stores/#{params[:id]}" } - action.proxy_http_verb = :get action.params_tracking_allowlist = %w[id] end end @@ -30,7 +29,6 @@ module Orders strangler.controller("api/orders/checkout") do |controller| controller.action("index") do |action| action.proxy_url = "http://example.com:8080/api/stores" - action.proxy_http_verb = :get end end end