Skip to content

feat: add region support for API base URLs - #20

Merged
cvejk merged 4 commits into
masterfrom
feature/region-support
Jul 2, 2026
Merged

cvejk merged 4 commits into
masterfrom
feature/region-support

Conversation

@cvejk

@cvejk cvejk commented Jul 1, 2026 •

Copy link
Copy Markdown

Description

Adds Region support to the Contentful client. A new SetRegion setter method allows switching all API base URLs to the corresponding regional endpoint (e.g. EU) without touching constructor signatures or breaking any existing code.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📝 Documentation
  • ♻️ Refactoring
  • ⚡ Performance
  • ✅ Tests
  • 🔧 Build/CI

Changes

  • Added Region string type with RegionUS = "us" and RegionEU = "eu" constants
  • Added SetRegion(region Region) *Contentful method on the client — rewrites BaseURL and UploadURL (CMA only) to the regional subdomain via a single strings.Replace
  • SetRegion("") and SetRegion(RegionUS) are strict no-ops — the client returns unchanged, all existing call sites are unaffected
  • Method is chainable: contentful.NewCDA(key).SetRegion(RegionEU)
  • Added TestSetRegion covering all four endpoints (CMA, CMA upload, CDA, CPA), the no-op guarantee, and chainability

Checklist

  • My code adheres to the coding and style guidelines of the project.
  • I have performed a self-review of my own code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.

@cvejk
cvejk requested a review from cvidmar July 1, 2026 12:31

@cvidmar cvidmar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cvejk
cvejk merged commit 122fe5c into master Jul 2, 2026
4 checks passed
@cvejk
cvejk deleted the feature/region-support branch July 2, 2026 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants