Priority
Medium — HTTP content negotiation correctness for generated query routes.
Context
runtime/app/backend.go routes contract query requests when either X-GOWDK-Query is truthy or the request Accept header appears to accept JSON.
The helper currently detects JSON with:
for _, part := range strings.Split(header, ",") {
mediaType := strings.ToLower(strings.TrimSpace(strings.Split(part, ";")[0]))
if mediaType == "application/json" || strings.HasSuffix(mediaType, "+json") {
return true
}
}
Problem
The parser ignores q quality values and other structured Accept-header semantics.
Examples:
Accept: application/json;q=0, text/html
This explicitly says JSON is unacceptable, but the current helper still returns true because it only checks the media type before ;.
Consequences:
- A request can be routed as a query request even when JSON has
q=0.
- Browser/tool content negotiation can behave unexpectedly.
- Future response negotiation is harder because the current helper is not a real Accept parser.
- Tests may encode an overly permissive contract.
Proposed direction
Use a small structured Accept parser for generated-runtime routing decisions.
The helper should at minimum:
- split media ranges safely;
- parse parameters;
- treat missing
q as 1;
- treat invalid
q values consistently;
- ignore JSON media ranges with
q=0;
- support
application/json and application/*+json.
Acceptance criteria
Related
Priority
Medium — HTTP content negotiation correctness for generated query routes.
Context
runtime/app/backend.goroutes contract query requests when eitherX-GOWDK-Queryis truthy or the requestAcceptheader appears to accept JSON.The helper currently detects JSON with:
Problem
The parser ignores
qquality values and other structured Accept-header semantics.Examples:
Accept: application/json;q=0, text/htmlThis explicitly says JSON is unacceptable, but the current helper still returns true because it only checks the media type before
;.Consequences:
q=0.Proposed direction
Use a small structured Accept parser for generated-runtime routing decisions.
The helper should at minimum:
qas1;qvalues consistently;q=0;application/jsonandapplication/*+json.Acceptance criteria
Accept: application/jsonstill marks a query request.Accept: application/problem+jsonor another+jsonmedia type still marks a query request.Accept: application/json;q=0, text/htmldoes not mark a query request unlessX-GOWDK-Queryis set.Related