Skip to content

feat: add per-call ContentType override via CallOptions#111

Merged
unrolled merged 1 commit into
unrolled:v1from
caueasantos:per-call-render-options
Apr 30, 2026
Merged

feat: add per-call ContentType override via CallOptions#111
unrolled merged 1 commit into
unrolled:v1from
caueasantos:per-call-render-options

Conversation

@caueasantos
Copy link
Copy Markdown
Contributor

Summary

Adds optional per-call options to Data, HTML, JSON, JSONP, Text, and XML, letting callers override the response Content-Type for a single call without spinning up a second Render instance.

Closes #109.

Changes

  • New CallOptions struct (with ContentType field) accepted as a trailing variadic argument by Data, JSON, JSONP, Text, and XML.
  • HTMLOptions gains a ContentType field, propagated through prepareHTMLOptions.
  • Internal resolveContentType helper centralizes the override logic.
  • When an override is supplied, the configured charset is not appended — callers are expected to provide a fully-formed Content-Type value.
  • All existing call sites continue to compile unchanged (variadic, backward compatible).

Testing

  • go build ./...
  • go vet ./...
  • go test -race ./...
  • Added TestXxxPerCallContentType for each of the six renderers.

Additional Context

The override path intentionally bypasses charset appending so callers retain full control of the header — for example, application/vnd.api+json already implies UTF-8 and shouldn't get a duplicate charset suffix.

@caueasantos caueasantos marked this pull request as ready for review April 28, 2026 02:30
@caueasantos caueasantos force-pushed the per-call-render-options branch from 2a32ad3 to 05ca08c Compare April 28, 2026 02:36
Copy link
Copy Markdown
Owner

@unrolled unrolled left a comment

Choose a reason for hiding this comment

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

Looks good!

@unrolled unrolled merged commit c2646b2 into unrolled:v1 Apr 30, 2026
6 of 7 checks passed
@caueasantos caueasantos deleted the per-call-render-options branch May 6, 2026 15:46
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.

Overriding options post-instantiation

2 participants