HttpTrigger Interface

public interface HttpTrigger

HttpTrigger(name = "req", methods = {HttpMethod.GET, HttpMethod.POST}, authLevel = AuthorizationLevel.ANONYMOUS) final HttpRequestMessage<Optional<String>> request) { String name = request.getBody().orElseGet(() -> request.getQueryParameters().get("name")); return name == null ? "Please pass a name on the query string or in the request body" : "Hello " + name; }

Method Summary

Modifier and Type Method and Description
AuthorizationLevel authLevel()

Determines what keys, if any, need to be present on the request in order to invoke the function. The authorization level can be one of the following values:

    <li>
    
      <p>
    
        <b>anonymous</b>: No API key is required. </p>
    
    </li>
    
    <li>
    
      <p>
    
        <b>function</b>: A function-specific API key is required. This is the default value if none is provided. </p>
    
    </li>
    
    <li>
    
      <p>
    
        <b>admin</b>: The master key is required. </p>
    
    </li>
    

For more information, see the documentation about authorization keys.

String dataType()

Defines how Functions runtime should treat the parameter value. Possible values are:

    <li>
    
      <p>"": get the value as a string, and try to deserialize to actual parameter type like POJO </p>
    
    </li>
    
    <li>
    
      <p>string: always get the value as a string </p>
    
    </li>
    
    <li>
    
      <p>binary: get the value as a binary data, and try to deserialize to actual parameter type byte[] </p>
    
    </li>
    

HttpMethod [] methods()

An array of the HTTP methods to which the function responds. If not specified, the function responds to all HTTP methods.

String name()

The variable name used in function code for the request or request body.

String route()

BindingName("id") int id, final ExecutionContext context ) { .... context.getLogger().info("We have " + category + " with id " + id); .... }

For more details on the route syntax, refer to the online documentation.

Method Details

authLevel

public AuthorizationLevel authLevel() default AuthorizationLevel.FUNCTION

Determines what keys, if any, need to be present on the request in order to invoke the function. The authorization level can be one of the following values:

    <li>
    
      <p>
    
        <b>anonymous</b>: No API key is required. </p>
    
    </li>
    
    <li>
    
      <p>
    
        <b>function</b>: A function-specific API key is required. This is the default value if none is provided. </p>
    
    </li>
    
    <li>
    
      <p>
    
        <b>admin</b>: The master key is required. </p>
    
    </li>
    

For more information, see the documentation about authorization keys.

Returns:

An AuthorizationLevel value representing the level required to access the function.

dataType

public String dataType() default ""

Defines how Functions runtime should treat the parameter value. Possible values are:

    <li>
    
      <p>"": get the value as a string, and try to deserialize to actual parameter type like POJO </p>
    
    </li>
    
    <li>
    
      <p>string: always get the value as a string </p>
    
    </li>
    
    <li>
    
      <p>binary: get the value as a binary data, and try to deserialize to actual parameter type byte[] </p>
    
    </li>
    

Returns:

The dataType which will be used by the Functions runtime.

methods

public HttpMethod [] methods() default

An array of the HTTP methods to which the function responds. If not specified, the function responds to all HTTP methods.

Returns:

An array containing all valid HTTP methods.

name

public String name()

The variable name used in function code for the request or request body.

Returns:

The variable name used in function code for the request or request body.

route

public String route() default ""

BindingName("id") int id, final ExecutionContext context ) { .... context.getLogger().info("We have " + category + " with id " + id); .... }

For more details on the route syntax, refer to the online documentation.

Returns:

The route template to use for the annotated function.

Applies to