Struct azure_functions::bindings::HttpRequest[][src]

pub struct HttpRequest<'a>(_);

Represents a HTTP trigger binding.

Examples

A function that responds with a friendly greeting:

use azure_functions::func;
use azure_functions::bindings::{HttpRequest, HttpResponse};

#[func]
#[binding(name = "request", auth_level = "anonymous")]
pub fn greet(request: &HttpRequest) -> HttpResponse {
    format!(
        "Hello, {}!",
        request.query_params().get("name").map_or("stranger", |x| x)
    ).into()
}

Invoking the above function as https://<app-name>.azurewebsites.net/api/greet?name=John would result in a response of Hello, John!.

Methods

impl<'a> HttpRequest<'a>
[src]

Gets the HTTP method (e.g. "GET") for the request.

Gets the URL of the request.

Gets the headers of the request.

Gets the route parameters of the request.

Route parameters are specified through the route argument of a HttpRequest binding attribute.

See Route Containts for syntax.

Examples

use azure_functions::func;
use azure_functions::bindings::{HttpRequest, HttpResponse};

#[func]
#[binding(name = "request", route = "users/{id:int}")]
pub fn users(request: &HttpRequest) -> HttpResponse {
    format!(
        "User ID requested: {}",
        request.route_params().get("id").unwrap()
    ).into()
}

Invoking the above function as https://<app-name>.azurewebsites.net/api/users/1234 would result in a response of User ID requested: 1234.

Gets the URL query parameters of the request.

Gets the body of the request.

Trait Implementations

impl<'a> Debug for HttpRequest<'a>
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl<'a> Send for HttpRequest<'a>

impl<'a> Sync for HttpRequest<'a>