Why can't I mix HTTPContext with QUERY or PATH parameters in an EK9 service method?
← Web Services · Ref: Q1330
When an EK9 service method binds the full request via :=: CONTEXT, the HTTPContext parameter must be the ONLY parameter. HTTPContext already exposes the complete request - query string, path segments, headers, body - so adding individual :=: QUERY or :=: PATH bindings alongside it is redundant and ambiguous, raising E07792.
You have two valid choices:
1. Use HTTPContext ALONE and extract everything you need from it inside the method body via its request accessors.
2. Use only individual qualified parameters (:=: PATH, :=: QUERY, :=: HEADER, :=: CONTENT) and do NOT take an HTTPContext at all.
See Q202 for parameter binding and Q945 for parameter qualifiers.
Example
defines module qa.webdeep.service.httpcontext defines constant JSON_TYPE <- "application/json" defines service <?- Search service demonstrating the correct use of HTTPContext. The method binds the full request via :=: CONTEXT and uses ONLY that single parameter. Any query or path values are read from the context inside the method body - never via a second :=: QUERY/PATH binding, which would raise E07792. -?> SearchService :/search open search() as GET for :/results -> ctx as HTTPContext :=: CONTEXT <- response as HTTPResponse: (reqId: ctx.requestId()) with trait HTTPResponse override content() <- rtn as String: `{"requestId": "${reqId}"}` override status() as pure <- rtn as Integer: 200 override contentType() as pure <- rtn as String: JSON_TYPE override cacheControl() as pure <- rtn as String: "no-cache" override contentLanguage() as pure <- rtn as String: "en" default operator ? defines application SearchApp register SearchService() defines program HttpContextDemo() stdout <- Stdout() stdout.println("HTTPContext must be the ONLY service-method parameter.") stdout.println("Read query and path values from the context inside the body,") stdout.println("never via a second :=: QUERY or :=: PATH binding (E07792).")
Common mistakes
E07792 — HTTPContext (:=: CONTEXT) already provides the entire request, so adding a second :=: QUERY binding alongside it is redundant and ambiguous, triggering E07792. See ek9 -h E07792 for details.
Incorrect:
-> ctx as HTTPContext :=: CONTEXT term as String :=: QUERY "q"
Correct:
-> ctx as HTTPContext :=: CONTEXT
Other ways to ask this
- What triggers E07792 HTTPContext mixed with other params?
- Why must HTTPContext be the only parameter in a service method?
- How do I access query and path values when using HTTPContext in EK9?
Coming from another language?
Java Spring: you may freely combine HttpServletRequest with @RequestParam/@PathVariable in the same handler - no compiler objection, even though the request object already contains those values. JAX-RS allows @Context HttpServletRequest beside @QueryParam. EK9 instead makes the redundancy a compile-time error (E07792): the all-encompassing HTTPContext and individual bindings are mutually exclusive, so a method has exactly one, unambiguous binding strategy.
Keywords: CONTEXT, PATH, QUERY, service, E07792, HTTPContext, binding, web, parameter