E07792: Web Service type HTTPContext can only be used by itself
What went wrong
You have HTTPContext parameter alongside other parameters, but HTTPContext must be the only parameter when used. It provides the full request context so individual bindings are redundant.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 1330 (Why can't I mix HTTPContext with QUERY or PATH paramet...)
How to fix it
- Use HTTPContext alone - extract values from it inside method
- Or use individual parameters without HTTPContext
The [EXAMPLE] section below shows a CONTEXT parameter beside a QUERY one, and the context taken alone.
Common causes
- Mixing HTTPContext with :=: QUERY/:=: PATH parameters
- Trying to have both context and individual params
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E07792: Web Service type HTTPContext can only be used by itself
#!ek9 defines module error.e07792.bad defines class TextResponse with trait of HTTPResponse text as String? default private TextResponse() TextResponse() -> body as String this.text: body override contentType() as pure <- rtn as String: "text/plain" override content() <- rtn as Bytes: Bytes().withUtf8(text) override status() as pure <- rtn as Integer: 200 default operator ? defines service Addresses for :/addresses open info() as GET for :/info -> //The context already holds every query value context as HTTPContext :=: CONTEXT filter as String :=: QUERY "q" <- response as HTTPResponse: TextResponse(`${context} ${filter}`)
Fixed: Take the context alone
#!ek9 defines module error.e07792.good defines class TextResponse with trait of HTTPResponse text as String? default private TextResponse() TextResponse() -> body as String this.text: body override contentType() as pure <- rtn as String: "text/plain" override content() <- rtn as Bytes: Bytes().withUtf8(text) override status() as pure <- rtn as Integer: 200 default operator ? defines service Addresses for :/addresses open info() as GET for :/info -> context as HTTPContext :=: CONTEXT <- response as HTTPResponse: TextResponse($context)
Questions and answers
These Q&A entries show E07792 and its fix: