opt: do not route to static assets for API path#1237
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the static file handler to distinguish between API routes, static assets, and SPA routes, ensuring that unknown API paths return a JSON 404 error instead of falling back to the SPA index. It also includes whitespace cleanups, indentation fixes in tests, and new unit tests for the static handler logic. I have no feedback to provide.
| clientUA: "Client/1.0", | ||
| wantUAHeader: "axonhub/1.0", // Pass-through disabled: middleware sets default UA | ||
| }, | ||
| name: "channel_disabled_ignores_global", |
There was a problem hiding this comment.
🔴 Rule violation: new(false) used instead of lo.ToPtr(false) — also invalid Go syntax
new(false) is used to create a *bool, but Go's builtin new takes a type, not a value — this won't compile. The backend rule in .agent/rules/backend.md:72 mandates using lo.ToPtr to get a pointer to a constant value. The rest of the orchestrator package consistently uses lo.ToPtr(false) for this purpose (e.g. candidates_stream_policy_test.go, transform_options_test.go).
| name: "channel_disabled_ignores_global", | |
| channelUASetting: lo.ToPtr(false), |
Was this helpful? React with 👍 or 👎 to provide feedback.
| wantUAHeader: "axonhub/1.0", // Pass-through disabled: middleware sets default UA | ||
| }, | ||
| { | ||
| name: "channel_enabled_ignores_global", |
There was a problem hiding this comment.
🔴 Rule violation: new(true) used instead of lo.ToPtr(true) — also invalid Go syntax
new(true) is used to create a *bool, but Go's builtin new takes a type, not a value — this won't compile. The backend rule in .agent/rules/backend.md:72 mandates using lo.ToPtr to get a pointer to a constant value. The rest of the orchestrator package consistently uses lo.ToPtr(true) for this purpose.
| name: "channel_enabled_ignores_global", | |
| channelUASetting: lo.ToPtr(true), |
Was this helpful? React with 👍 or 👎 to provide feedback.
| @@ -1836,7 +1837,7 @@ func TestApplyUserAgentPassThrough(t *testing.T) { | |||
| }, | |||
| { | |||
| name: "enabled_but_no_client_ua", | |||
There was a problem hiding this comment.
🔴 Rule violation: new(true) used instead of lo.ToPtr(true) — also invalid Go syntax
Same issue as the other instances: new(true) is invalid Go (builtin new takes a type, not a value) and violates the backend rule in .agent/rules/backend.md:72 that mandates lo.ToPtr for pointer-to-constant values.
| name: "enabled_but_no_client_ua", | |
| channelUASetting: lo.ToPtr(true), |
Was this helpful? React with 👍 or 👎 to provide feedback.
Uh oh!
There was an error while loading. Please reload this page.