How do HTTP verbs, URI path variables, and parameter qualifiers work in EK9 services?
← Web Services · Ref: Q945
EK9 service methods require explicit HTTP configuration:
1. HTTP VERB REQUIRED (E07680)
Every method needs an HTTP verb: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS.
2. URI PATH REQUIRED (E07690)
Methods must specify a URI path after 'for :/path'.
3. PARAMETER QUALIFIERS (E07710)
Parameters in service methods need qualifiers like PATH, QUERY, HEADER, COOKIE, or REQUEST. Path variables are bound automatically from URI segments.
4. NO DUPLICATE QUALIFIERS (E07720)
Each parameter qualifier can only be used once per method.
See Q657 for URI mapping. See Q846 for parameter types. See Q868 for path parameter types.
Example
defines module qa.services.uripath.params defines constant JSON_TYPE <- "application/json" defines class <?- Models a user lookup response. Demonstrates how path variables bind to parameters in services. -?> UserResponse userId as Integer: 0 contentKind as String: JSON_TYPE UserResponse() -> givenUserId as Integer this.userId :=: givenUserId userId() <- rtn as Integer: Integer(userId) contentKind() <- rtn as String: String(contentKind) toJson() <- rtn as String: `{"userId": ${userId}}` operator $ as pure <- rtn as String: `UserResponse[${userId}]` operator #^ as pure <- rtn as String: $this default operator ? <?- Models a user list response. -?> UserListResponse userCount as Integer: 0 UserListResponse() -> givenCount as Integer this.userCount :=: givenCount toJson() <- rtn as String: `{"users": [], "count": ${userCount}}` operator $ as pure <- rtn as String: `UserListResponse[${userCount}]` operator #^ as pure <- rtn as String: $this default operator ? <?- Simulates a user service with path parameter binding. In real services, GET /users/{userId} binds userId from the URI. -?> UserEndpoint findUser() -> userId as Integer <- rtn as UserResponse: UserResponse(userId) listUsers() <- rtn as UserListResponse: UserListResponse(0) operator $ as pure <- rtn as String: "UserEndpoint" operator #^ as pure <- rtn as String: $this default operator ? defines program ServiceUriParamsDemo() stdout <- Stdout() endpoint <- UserEndpoint() userResult <- endpoint.findUser(42) listResult <- endpoint.listUsers() stdout.println("Service URI parameters:") stdout.println(" GET /users/{userId} -> path variable binding") stdout.println(" GET /users/list -> no parameters") stdout.println(userResult.toJson()) stdout.println(listResult.toJson())
Other ways to ask this
- What triggers E07680 SERVICE_HTTP_VERB_REQUIRED?
- What triggers E07690 SERVICE_URI_PATH_REQUIRED?
- What triggers E07710 SERVICE_PARAM_NEEDS_QUALIFIER?
- What triggers E07720 SERVICE_DUPLICATE_QUALIFIER?
- How do I bind path variables to parameters?
Coming from another language?
Java Spring: @GetMapping, @PathVariable, @RequestParam. Python Flask: @app.route with <param>. Go: mux.Vars(r) for path variables. EK9: HTTP verb and URI path required in method signature, parameters bound from path segments.
Keywords: path, parameter, E07720, E07690, URI, HTTP, E07710, E07680, verb, service