HTTP Trigger

Invoke functions over HTTP by mapping URL paths and methods to functions with fission httptrigger create, including URL path parameters.

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_ROUTER is the externally-visible address of your Fission router service. For how to set the FISSION_ROUTER environment 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.25.0, the URL path and prefix of an HTTP trigger are validated by both the fission CLI and the Kubernetes API server (via CEL x-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 via kubectl apply or GitOps is rejected just like one created with the CLI.

Ingress

To expose an HTTP 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

You can attach annotations and TLS to the generated Ingress:

  • --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, for example:

Other controllers such as F5 and Kong also work.