Skip to content

fix(static): preserve matched handler 404s#3043

Open
JSap0914 wants to merge 2 commits into
labstack:masterfrom
JSap0914:fix/2775-preserve-matched-handler-not-found
Open

fix(static): preserve matched handler 404s#3043
JSap0914 wants to merge 2 commits into
labstack:masterfrom
JSap0914:fix/2775-preserve-matched-handler-not-found

Conversation

@JSap0914

@JSap0914 JSap0914 commented Jul 14, 2026

Copy link
Copy Markdown

Fixes #2775

Preserves 404 responses from matched handlers when HTML5 static fallback is enabled, while retaining the index fallback for router misses, including group route-not-found handling.

Verification:

  • go test -race ./middleware -run '^TestStaticHTML5PreservesMatchedHandlerNotFound$' -count=1
  • go test -race ./middleware -run '^TestStatic$/^ok,_when_html5_mode_serve_index_for_any_static_file_that_does_not_exist$' -count=1
  • go test -race ./middleware

Comment thread middleware/static_test.go

}

func TestStaticHTML5PreservesMatchedHandlerNotFound(t *testing.T) {

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.

please separate these 2 'test cases' by table tests of something like that.

@JSap0914

Copy link
Copy Markdown
Author

Refactored the two test cases into a table-driven test in middleware/static_test.go as requested. go test ./middleware/ -run TestStatic passes.

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.

Not found error conflict with StaticWithConfig middleware

2 participants