HTTP Trigger

An HTTP trigger invokes a function when there is an HTTP request.

You can specify the relative URL and HTTP method for a trigger:

$ fission httptrigger create --url /hello --method GET --function hello
trigger '94cd5163-30dd-4fb2-ab3c-794052f70841' created

$ curl http://$FISSION_ROUTER/hello
Hello World!

To add authentication to your function calls, refer to our Fission Authentication guide.

FISSION_ROUTER is the externally-visible address of your Fission router service. For how to set up environment variable FISSION_ROUTER, see here

Also, we can create a trigger contains URL parameter by putting placeholders in value of --url flag.

$ fission httptrigger create --method GET \
    --url "/guestbook/messages/{id}" --function restapi-get

Since fission uses gorilla/mux as underlying URL router, you can write regular expression to filter out illegal API requests.

$ fission httptrigger create --method GET \
    --url "/guestbook/messages/{id:[0-9]+}" --function restapi-get
Learn how to access URL parameters in function to develop a REST API, please visit here

If you want to use Kubernetes Ingress for the HTTP Trigger, you can provide the --createingress flag and a hostname. If the hostname is not provided, it defaults to “*”, which indicates a wildcard host.

$ fission httptrigger create --url /hello --method GET --function hello --createingress --host acme.com
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

Please note that for ingress to work, you will have to deploy an ingress controller in Kubernetes cluster. Kubernetes currently supports and maintains the following ingress controllers:

Other Ingress controllers exist, such as F5 networks and Kong.