Skip to content

docs(middleware): clarify MethodOverrideGetter return value#3059

Open
sonnemusk wants to merge 2 commits into
labstack:masterfrom
sonnemusk:fix/method-override-normalize-case
Open

docs(middleware): clarify MethodOverrideGetter return value#3059
sonnemusk wants to merge 2 commits into
labstack:masterfrom
sonnemusk:fix/method-override-normalize-case

Conversation

@sonnemusk

@sonnemusk sonnemusk commented Jul 22, 2026

Copy link
Copy Markdown

Summary

Per review feedback: normalizing override methods (upper-case / trim) is not the middleware's job.

This PR only documents that MethodOverrideGetter should return a standard HTTP method name (e.g. http.MethodDelete / "DELETE"). No runtime behavior change.

Test plan

  • docs only

Overridden methods such as "delete" did not match router http.Method*
constants. Trim and uppercase the override value before assigning.
Comment thread middleware/method_override.go Outdated
req := c.Request()
if req.Method == http.MethodPost {
m := config.Getter(c)
m := strings.TrimSpace(config.Getter(c))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I do not think fixing invalid http method (removing spaces or upper-casing) is middleware task.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we could add comment config.Getter what it should output.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in the latest commit: runtime normalization removed; Getter docs now state it should return a standard method name (e.g. http.MethodDelete).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in the latest commit: runtime normalization removed; Getter docs now state it should return a standard method name (e.g. http.MethodDelete).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done — MethodOverrideGetter godoc now documents that it should return a standard method name such as http.MethodDelete / "DELETE", and that the middleware does not normalize case or trim spaces.

Per review: do not normalize override methods in middleware. Document that
Getter should return a standard method name (e.g. http.MethodDelete).
@sonnemusk sonnemusk changed the title fix(middleware): normalize MethodOverride method to uppercase docs(middleware): clarify MethodOverrideGetter return value Jul 22, 2026
@sonnemusk

Copy link
Copy Markdown
Author

Thanks — agreed. I dropped the upper-case/trim runtime change and only documented that `MethodOverrideGetter` should return a standard method name (e.g. `http.MethodDelete`). Please take another look.

@sonnemusk
sonnemusk force-pushed the fix/method-override-normalize-case branch from 1ec77ec to a4dd591 Compare July 22, 2026 07:56
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