HTTP Trigger
An HTTP trigger invokes a function when the router receives a matching HTTP request. You map a URL path and one or more HTTP methods to a function, and the router forwards matching requests to it.
Create a basic trigger
Map GET /hello to the hello function:
$ fission httptrigger create --url /hello --method GET --function hello
trigger '94cd5163-30dd-4fb2-ab3c-794052f70841' created
$ curl http://$FISSION_ROUTER/hello
Hello World!
To send multiple methods to the same function, repeat --method:
$ fission httptrigger create --url /hello --method GET --method POST --function hello
FISSION_ROUTERis the externally-visible address of your Fission router service. For how to set theFISSION_ROUTERenvironment variable, see Accessing Fission environment variables.
To add authentication to your function calls, see the Fission Authentication guide.
URL parameters
Add placeholders to the --url value to capture path parameters:
$ fission httptrigger create --method GET \
--url "/guestbook/messages/{id}" --function restapi-get
Fission uses gorilla/mux as the underlying URL router, so you can constrain a parameter with a regular expression to reject malformed requests:
$ fission httptrigger create --method GET \
--url "/guestbook/messages/{id:[0-9]+}" --function restapi-get
To read URL parameters inside your function and build a REST API, see Accessing URL parameters.
Prefix routing
Use --prefix to forward every request under a path to one function.
Prefix takes precedence over --url.
By default the prefix is stripped before the request reaches the function; pass --keepprefix to forward the full path instead.
$ fission httptrigger create --prefix /api --method GET --function api-gateway
Path safety
As of Fission v1.27.0, the URL path and prefix of an HTTP trigger are validated by both thefissionCLI and the Kubernetes API server (via CELx-kubernetes-validations). A path must start with/, must not be root-only (/), and must not contain..traversal segments. It also may not collide with router-owned paths (/router-healthz,/readyz,/_version,/auth/login) or shadow the router-internal/fission-function/prefix. Because the rules now run in the API server, a trigger written viakubectl applyor GitOps is rejected just like one created with the CLI.
Exposing a trigger externally
By default a trigger is reachable at the router’s address.
To expose it on its own host and path, attach a route provider with the --route-provider flag.
The Kubernetes Ingress API is frozen, so the Gateway API is the recommended way to expose a trigger externally. The--createingress/--ingress*flags still work but are deprecated — the CLI prints a deprecation warning when you use them, and--route-providertakes precedence over--createingress.
Gateway API (recommended)
Point the trigger at a parent Gateway with --route-provider gateway; Fission creates a gateway.networking.k8s.io HTTPRoute attached to it:
fission httptrigger create --url /hello --method GET --function hello \
--route-provider gateway --gateway my-gateway --route-host acme.com --route-path /hello
--gateway name(ornamespace/name, repeatable) — the parent Gateway theHTTPRouteattaches to.--route-host demo.example.com(repeatable) — the hostname the route matches; empty matches all hosts.--route-path /hello— the request path the route matches; defaults to the trigger URL/prefix.--route-annotation key=value(repeatable) — annotation added to the generated route object.
Set gatewayAPI.enabled=true in the chart first, and run a Gateway API implementation (Envoy Gateway, Istio, NGINX Gateway Fabric, …).
See Exposing functions with the Gateway API for the full setup.
Ingress (deprecated)
To expose a trigger through a Kubernetes Ingress, pass --createingress and set the host and path with --ingressrule host=path.
If you create an Ingress without a rule, the host defaults to *, a wildcard host.
$ fission httptrigger create --url /hello --method GET --function hello --createingress --ingressrule acme.com=/hello
trigger '94cd5163-30dd-4fb2-ab3c-794052f70841' created
$ fission route list
NAME METHOD HOST URL INGRESS FUNCTION_NAME
94cd5163-30dd-4fb2-ab3c-794052f70841 GET acme.com /hello true hello
--ingressrule host=path— set the Ingress host and path rule.--ingressannotation key=value— add an annotation (repeatable); the format depends on your Ingress controller.--ingresstls secretName— reference a Secret holding the TLS key and certificate.
For Ingress to work, you must deploy an Ingress controller in your cluster. See Exposing functions with Ingress for controller examples and extra settings.