[−][src]Struct azure_functions::bindings::HttpRequest
Represents a HTTP trigger binding.
Examples
A function that responds with a friendly greeting:
use azure_functions::{ bindings::{HttpRequest, HttpResponse}, func, }; #[func] pub fn greet(request: &HttpRequest) -> HttpResponse { format!( "Hello, {}!", request.query_params().get("name").map_or("stranger", |x| x) ).into() }
Methods
impl HttpRequest
[src]
pub fn method(&self) -> &str
[src]
Gets the HTTP method (e.g. "GET") for the request.
pub fn url(&self) -> &str
[src]
Gets the URL of the request.
pub fn headers(&self) -> &HashMap<String, String>
[src]
Gets the headers of the request.
The header keys are lower-cased.
pub fn route_params(&self) -> &HashMap<String, String>
[src]
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
.
pub fn query_params(&self) -> &HashMap<String, String>
[src]
Gets the query parameters of the request.
The query parameter keys are case-sensative.
Examples
use azure_functions::func; use azure_functions::bindings::{HttpRequest, HttpResponse}; #[func] pub fn users(request: &HttpRequest) -> HttpResponse { format!( "The 'name' query parameter is: {}", request.query_params().get("name").map_or("undefined", |x| x) ).into() }
pub fn body(&self) -> Body
[src]
Gets the body of the request.
Trait Implementations
impl From<TypedData> for HttpRequest
[src]
impl Debug for HttpRequest
[src]
Auto Trait Implementations
impl Send for HttpRequest
impl Sync for HttpRequest
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.