E07791: Web Service parameter type must be HTTPContext for CONTEXT
What went wrong
You're using CONTEXT parameter binding but the parameter type isn't HTTPContext. The CONTEXT qualifier provides access to the request context (authenticated principal, security state, connection metadata).
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 1329 (Why must a CONTEXT-bound service parameter be typed HT...)
How to fix it
- Use HTTPContext type with :=: CONTEXT
- For individual values, use specific access types (:=: QUERY, :=: PATH)
The [EXAMPLE] section below shows ':=: CONTEXT' on a String, and on an HTTPContext.
Common causes
- Using String or other types with CONTEXT qualifier
- Confusion between CONTENT (String body) and CONTEXT (request metadata)
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E07791: Web Service parameter type must be HTTPContext for CONTEXT
#!ek9 defines module error.e07791.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 -> //CONTEXT is an HTTPContext context as String :=: CONTEXT <- response as HTTPResponse: TextResponse(context)
Fixed: Take CONTEXT as an HTTPContext
#!ek9 defines module error.e07791.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 E07791 and its fix: