Skip to content

Add header parameter support#31

Merged
moutonjeremy merged 13 commits intomainfrom
feat-header-catch
Feb 7, 2026
Merged

Add header parameter support#31
moutonjeremy merged 13 commits intomainfrom
feat-header-catch

Conversation

@moutonjeremy
Copy link
Member

Enhance input handling by adding support for header parameters

Copilot AI review requested due to automatic review settings February 7, 2026 00:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for header:"..." struct tags so request headers can be bound into handler input structs and emitted as OpenAPI parameters (with header-tagged fields excluded from request-body schemas).

Changes:

  • Parse request headers into input structs via a new parseHeaderParams step in parseInput.
  • Generate OpenAPI parameters for header-tagged fields and exclude them from request-body schema generation.
  • Add tests and update examples/dependency metadata to demonstrate header parameters.

Reviewed changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
header_params_test.go Adds coverage for header binding + OpenAPI parameter generation (including pointer-type schema expectations).
fiberoapi.go Excludes header-tagged fields from request body schema generation.
common.go Adds header parsing and OpenAPI extraction for header tags.
_examples/simple/main.go Demonstrates using a required header parameter in an example route.
_examples/simple/go.mod Updates example module metadata and adds a local replace for development.
_examples/simple/go.sum Updates example dependency checksums after module changes.
_examples/auto_params/go.mod Dependency version bumps in example module.
_examples/auto_params/go.sum Dependency checksum updates for example module.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 8 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

common.go:53

  • parseInput binds header params before calling c.BodyParser(&input). Because BodyParser runs afterwards, a request body can overwrite fields that are meant to come from headers (and can even satisfy validate:"required" without the header being present). This also conflicts with the OpenAPI generation which now excludes header-tagged fields from the request-body schema. Consider preventing body parsing from touching path/query/header-tagged fields (e.g., custom unmarshal that skips them), or parsing the body into a separate struct and then overlaying path/query/header values with presence checks for required header fields.
	// Parse header parameters
	err = parseHeaderParams(c, &input)
	if err != nil {
		return input, err
	}

	// Parse body for POST/PUT methods only if there's content
	method := c.Method()
	if method == "POST" || method == "PUT" || method == "PATCH" {
		// Check if there's content in the body
		bodyLength := len(c.Body())
		contentType := c.Get("Content-Type")

		// Parse the body if there's content OR if it's a POST/PUT/PATCH with specified Content-Type
		if bodyLength > 0 || strings.Contains(contentType, "application/json") || strings.Contains(contentType, "application/x-www-form-urlencoded") {
			err = c.BodyParser(&input)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 8 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@moutonjeremy moutonjeremy merged commit 13220cb into main Feb 7, 2026
4 checks passed
@moutonjeremy moutonjeremy deleted the feat-header-catch branch February 7, 2026 01:39
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.

1 participant

Comments