-
Notifications
You must be signed in to change notification settings - Fork 472
API Versioning, using a Bridge version, details
Eduardo J. edited this page Jan 12, 2026
·
1 revision
Suggested implementation details
- Mapping all current legacy endpoints to a new
/api/v1/prefix to establish a formal versioning standard without altering existing logic.# config/routes.rb Rails.application.routes.draw do # 1. New Versioned Routes namespace :api do namespace :v1 do resources :users end # 2. Beta Routes (Pointing to V2 module early) scope 'v2beta', module: 'v2' do resources :users end end # 3. Legacy Routes (Point to V1 to avoid duplication) # This ensures existing clients don't break. scope module: 'api/v1', defaults: { legacy_route: true } do resources :users, only: [:index, :show] end end
- Marking legacy routes as deprecated via HTTP headers to nudge users toward the
/api/v1/path.# app/controllers/api/v1/base_controller.rb module Api module V1 class BaseController < ActionController::API before_action :check_for_legacy_usage private def check_for_legacy_usage # Identify if the request reached the controller via a legacy route return unless params[:legacy_route] # Standard RFC headers for deprecation # Warning: 299 is the code for miscellaneous persistent warnings response.headers['Warning'] = '299 - "This endpoint is legacy. Please migrate to /api/v1/." ' response.headers['Deprecation'] = 'true' # Link header provides the client with the correct alternative URL new_path = "/api/v1#{request.path}" response.headers['Link'] = "<#{request.base_url}#{new_path}>; rel='alternate'" end end end end
- Development Environment Overview
- Development Environment Tips & Tricks
- Spec-Tips
- Code Style
- Rubocop
- Testing with VCR
- Test in kanku
- Authentication
- Authorization
- Autocomplete
- BS Requests
- Events
- ProjectLog
- Notifications
- Feature Toggles
- Build Results
- Attrib classes
- Flags
- The BackendPackage Cache
- Maintenance classes
- Cloud uploader
- Delayed Jobs
- Staging Workflow
- StatusHistory
- OBS API
- Owner Search
- Search
- Links
- Distributions
- Repository
- Data Migrations
- Package Versions
- next_rails
- Ruby Update
- Rails Profiling
- Remote Pairing Setup Guide
- Factory Dashboard
- osc
- Setup an OBS Development Environment on macOS
- Run OpenQA smoketest locally
- Responsive Guidelines
- Importing database dumps
- Problem Statement & Solution
- Kickoff New Stuff
- New Swagger API doc
- Documentation and Communication
- GitHub Actions
- Brakeman
- How to Introduce Software Design Patterns
- Query Objects
- Services
- View Components
- RFC: Core Components
- RFC: Decorator Pattern
- RFC: Backend models
- RFC: Hotwire Turbo Frames Pattern