category
http_router
Declarative HTTP router category for objects implementing the http_handler_protocol protocol.
logtalk_load(http_router(loader))staticPublic predicates
handle/2
Routes a normalized HTTP request using the importing object route/4 clauses.
statichandle(Request,Response)handle(+compound,-compound) - one_or_errordomain_error(http_router_middleware,Handler)domain_error(http_router_middleware_action,Action)domain_error(http_router_response_middleware,Handler)domain_error(http_router_response_middleware_response,Response)domain_error(http_router_route_authorization_action,Action)produces declaration is not a non-empty list of media types:domain_error(http_router_route_produces,ProducedMediaTypes)produces media type is invalid:domain_error(http_router_route_media_type,ProducedMediaType)domain_error(http_router_route_metadata,Metadata)domain_error(http_router_route_metadata_property,MetadataProperty)domain_error(http_router_handler,Handler)domain_error(http_router_path_template,Template)domain_error(http_router_path_template_segment,Segment)domain_error(http_router_path,Path)error(http_parameter_validation(Errors),Context)api_info/1
Returns the top-level OpenAPI info descriptor used when a router object also implements the open_api_provider_protocol protocol. Importing objects can override the default descriptor by defining open_api_info/1.
staticapi_info(Info)api_info(-compound) - oneservers/1
Returns the OpenAPI server descriptors used when a router object also implements the open_api_provider_protocol protocol. Importing objects can override the default empty list by defining open_api_servers/1.
staticservers(Servers)servers(-list(compound)) - onesecurity/1
Optional OpenAPI top-level security hook passthrough used when a router object also implements the open_api_provider_protocol protocol. Importing objects can define open_api_security/1 to expose top-level security requirements.
staticsecurity(Security)security(-list(compound)) - zero_or_oneoperations/1
Derives OpenAPI operation descriptors from route/4, route_metadata/2, and route_produces/2 when a router object also implements the open_api_provider_protocol protocol. Recognized route metadata terms are summary/1, description/1, tags/1, deprecated/1, security/1, parameters/1, request_body/1, and responses/1. When request_body/1 or responses/1 metadata is absent, the router first checks optional route_open_api_request_body_example/2 and route_open_api_response_example/2 hooks and then attempts to infer inline request and response schemas by probing the route handler with a synthetic annotated request. Explicit metadata always takes precedence over inferred descriptors.
staticoperations(Operations)operations(-list(compound)) - oneschema/2
Optional OpenAPI schema hook passthrough used when a router object also implements the open_api_provider_protocol protocol. Importing objects can define open_api_schema/2 to expose reusable schemas referenced by derived route operations.
staticschema(Name,Schema)schema(?atom,?compound) - zero_or_moresecurity_scheme/2
Optional OpenAPI security scheme hook passthrough used when a router object also implements the open_api_provider_protocol protocol. Importing objects can define open_api_security_scheme/2 to expose reusable security schemes referenced by derived route operations.
staticsecurity_scheme(Name,SecurityScheme)security_scheme(?atom,?compound) - zero_or_moreProtected predicates
middleware/2
Optional hook predicate that enumerates ordered middleware descriptors. Id is the middleware identifier and Handler is the name of a declared local predicate with arity 2, typically protected, that receives the current request and returns either continue(Request) or respond(Response).
staticmiddleware(Id,Handler)middleware(?atom,?atom) - zero_or_moreresponse_middleware/2
Optional hook predicate that enumerates ordered response middleware descriptors. Id is the middleware identifier and Handler is the name of a declared local predicate with arity 3, typically protected, that receives the request used to produce the current response and returns the transformed response. Routed requests preserve their route metadata annotations and negotiated media type, when applicable.
staticresponse_middleware(Id,Handler)response_middleware(?atom,?atom) - zero_or_moreroute/4
Hook predicate that enumerates route descriptors. Id is the route identifier, Method is a lowercase HTTP method atom, PathTemplate is a path-template atom using literal segments, anonymous * wildcard segments, and optional plain or typed placeholders such as {id}, {id:integer}, and {score:number}, and Handler is the name of a declared local predicate with arity 2, typically protected, that receives the annotated request and returns the response.
staticroute(Id,Method,PathTemplate,Handler)route(?atom,?atom,?atom,?atom) - zero_or_moreroute_metadata/2
Optional hook predicate that declares additional metadata properties for a route. When defined, Metadata must be a list of compound terms. The router removes any existing request properties with the same functors, prepends the metadata to the matched request, and then adds the standard route/1 and path_params/1 annotations.
staticroute_metadata(Id,Metadata)route_metadata(?atom,?list(compound)) - zero_or_oneroute_open_api_request_body_example/2
Optional hook predicate that enumerates example request bodies for OpenAPI inference. Each Body must be either empty or a normalized content(MediaType, Payload) term. These examples are only consulted when explicit request_body/1 route metadata is absent.
staticroute_open_api_request_body_example(Id,Body)route_open_api_request_body_example(?atom,?compound) - zero_or_moreroute_open_api_response_example/2
Optional hook predicate that enumerates example normalized HTTP responses for OpenAPI inference. These examples are only consulted when explicit responses/1 route metadata is absent.
staticroute_open_api_response_example(Id,Response)route_open_api_response_example(?atom,?compound) - zero_or_moreopen_api_info/1
Hook predicate that importing router objects can override to customize the default top-level OpenAPI info descriptor.
staticopen_api_info(Info)open_api_info(-compound) - oneopen_api_servers/1
Hook predicate that importing router objects can override to customize the default OpenAPI server descriptors.
staticopen_api_servers(Servers)open_api_servers(-list(compound)) - oneopen_api_security/1
Optional hook predicate that importing router objects can define to expose top-level OpenAPI security requirements.
staticopen_api_security(Security)open_api_security(-list(compound)) - zero_or_oneopen_api_schema/2
Optional hook predicate that importing router objects can define to expose reusable OpenAPI schemas.
staticopen_api_schema(Name,Schema)open_api_schema(?atom,?compound) - zero_or_moreopen_api_security_scheme/2
Optional hook predicate that importing router objects can define to expose reusable OpenAPI security schemes.
staticopen_api_security_scheme(Name,SecurityScheme)open_api_security_scheme(?atom,?compound) - zero_or_moreroute_produces/2
Optional hook predicate that declares the response media types produced by a route. When defined, MediaTypes must be a non-empty list of media type atoms. The router negotiates the request Accept header against this list, annotates successful matches with response_media_type(MediaType), and returns 406 Not Acceptable when no produced type matches.
staticroute_produces(Id,MediaTypes)route_produces(?atom,?list(atom)) - zero_or_onepath_template_parameters/2
Returns the normalized placeholder descriptors declared in a path template as parameter(Name, Type) terms.
staticpath_template_parameters(PathTemplate,Parameters)path_template_parameters(+atom,-list(compound)) - one_or_errorPathTemplate is not a valid router path template:domain_error(http_router_path_template,PathTemplate)PathTemplate is not a valid router path template segment:domain_error(http_router_path_template_segment,Segment)route_not_found_response/2
Optional hook predicate that customizes 404 Not Found responses. When defined by the importing object, it is called with the unmatched request and must return the response to send.
staticroute_not_found_response(Request,Response)route_not_found_response(+compound,-compound) - zero_or_oneroute_bad_request_response/3
Optional hook predicate that customizes 400 Bad Request responses generated from dedicated parameter-validation exceptions raised by route handlers. When defined by the importing object, it is called with the routed request, the structured parameter error list, and must return the response to send.
staticroute_bad_request_response(Request,Errors,Response)route_bad_request_response(+compound,+list(compound),-compound) - zero_or_oneroute_method_not_allowed_response/3
Optional hook predicate that customizes 405 Method Not Allowed responses. When defined by the importing object, it is called with the request, the effective allowed methods list as lowercase atoms, and must return the response to send.
staticroute_method_not_allowed_response(Request,AllowedMethods,Response)route_method_not_allowed_response(+compound,+list(atom),-compound) - zero_or_oneroute_automatic_options_response/3
Optional hook predicate that customizes automatic OPTIONS responses when no explicit options route matches. When defined by the importing object, it is called with the annotated synthetic request, the effective allowed methods list as lowercase atoms, and must return the response to send.
staticroute_automatic_options_response(Request,EffectiveMethods,Response)route_automatic_options_response(+compound,+list(atom),-compound) - zero_or_oneroute_not_acceptable_response/3
Optional hook predicate that customizes 406 Not Acceptable responses. When defined by the importing object, it is called with the request, the normalized produced media types for the matched route, and must return the response to send.
staticroute_not_acceptable_response(Request,ProducedMediaTypes,Response)route_not_acceptable_response(+compound,+list(atom),-compound) - zero_or_onePrivate predicates
(no local declarations; see entity ancestors if any)
Operators
(none)