Skip to content

Commit

Permalink
use filter params constant to bypass versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
jefftmarks committed Mar 6, 2025
1 parent 3ef2686 commit 31a8346
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/v1/lcpe/lacs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def list
def index_params
return @index_params if defined?(@index_params)

@index_params = params.permit(:edu_lac_type_nm, :state, :lac_nm, :page, :per_page)
@index_params = params.permit(*FILTER_PARAMS)
end

def page
Expand Down
8 changes: 3 additions & 5 deletions app/controllers/v1/lcpe_base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class PreloadVersionStaleError < StandardError; end

rescue_from PreloadVersionStaleError, with: :version_invalid

FILTER_PARAMS = %i[edu_lac_type_nm state lac_nm page per_page].freeze

private

def validate_preload_version
Expand Down Expand Up @@ -35,11 +37,7 @@ def set_headers(preload_version)

# If additional filter params present, bypass versioning
def bypass_versioning?
scrubbed_params.present?
end

def scrubbed_params
params.except(:format, :controller, :action, controller_name.singularize.to_sym)
params.keys.map(&:to_sym).intersect?(FILTER_PARAMS)
end

def version_invalid
Expand Down

0 comments on commit 31a8346

Please sign in to comment.