Skip to content

Pass ServeHeaderOptions by value instead of pointer, fine tune httplib tests#36982

Merged
lunny merged 4 commits into
mainfrom
copilot/refactor-serve-header-options
Mar 25, 2026
Merged

Pass ServeHeaderOptions by value instead of pointer, fine tune httplib tests#36982
lunny merged 4 commits into
mainfrom
copilot/refactor-serve-header-options

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 25, 2026

Pass ServeHeaderOptions by value instead of pointer across all call sites — no nil-check semantics are needed and the struct is small enough that copying is fine.

Changes

  • services/context/base.go: SetServeHeaders and ServeContent accept ServeHeaderOptions (value, not pointer); internal unsafe pointer cast replaced with a clean type conversion
  • routers/api/packages/helper/helper.go: ServePackageFile variadic changed from ...*context.ServeHeaderOptions to ...context.ServeHeaderOptions; internal variable is now a value type
  • All call sites (13 files): &context.ServeHeaderOptions{...}context.ServeHeaderOptions{...}

Before/after at the definition level:

// Before
func (b *Base) SetServeHeaders(opt *ServeHeaderOptions) { ... }
func (b *Base) ServeContent(r io.ReadSeeker, opts *ServeHeaderOptions) { ... }
func ServePackageFile(..., forceOpts ...*context.ServeHeaderOptions) { ... }

// After
func (b *Base) SetServeHeaders(opts ServeHeaderOptions) { ... }
func (b *Base) ServeContent(r io.ReadSeeker, opts ServeHeaderOptions) { ... }
func ServePackageFile(..., forceOpts ...context.ServeHeaderOptions) { ... }

⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 25, 2026
Copilot AI changed the title [WIP] Refactor ServeHeaderOptions to use structs instead of pointers refactor: use value semantics for ServeHeaderOptions parameters Mar 25, 2026
Copilot AI requested a review from wxiaoguang March 25, 2026 17:47
@wxiaoguang wxiaoguang marked this pull request as ready for review March 25, 2026 17:49
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 25, 2026
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 25, 2026
@lunny lunny added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Mar 25, 2026
@wxiaoguang wxiaoguang marked this pull request as draft March 25, 2026 18:31
@wxiaoguang wxiaoguang marked this pull request as ready for review March 25, 2026 18:51
@wxiaoguang wxiaoguang changed the title refactor: use value semantics for ServeHeaderOptions parameters Pass ServeHeaderOptions by value instead of pointer, fine tune httplib tests Mar 25, 2026
@lunny lunny merged commit a3cc344 into main Mar 25, 2026
30 checks passed
@lunny lunny deleted the copilot/refactor-serve-header-options branch March 25, 2026 23:08
@GiteaBot GiteaBot added this to the 1.26.0 milestone Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/refactoring Existing code has been cleaned up. There should be no new functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants