[][src]Struct rocket_lamb::RocketHandlerBuilder

pub struct RocketHandlerBuilder { /* fields omitted */ }

A builder to create and configure a RocketHandler.

Methods

impl RocketHandlerBuilder[src]

pub fn new(rocket: Rocket) -> RocketHandlerBuilder[src]

Create a new RocketHandlerBuilder. Alternatively, you can use rocket.lambda().

Example

use rocket_lamb::RocketHandlerBuilder;

let builder = RocketHandlerBuilder::new(rocket::ignite());

pub fn into_handler(self) -> RocketHandler[src]

Creates a new RocketHandler from an instance of Rocket, which can be passed to the lambda_http::lambda! macro.

Alternatively, you can use the launch() method.

Example

use rocket_lamb::RocketExt;
use lambda_http::lambda;

let handler = rocket::ignite().lambda().into_handler();
lambda!(handler);

pub fn launch(self) -> ![src]

Starts handling Lambda events by polling for events using Lambda's Runtime APIs.

This function does not return, as it will loop forever (unless it panics).

Panics

This panics if the required Lambda runtime environment variables are not set, or if the Rocket used to create the builder was misconfigured.

Example

use rocket_lamb::RocketExt;
use lambda_http::lambda;

rocket::ignite().lambda().launch();

pub fn get_default_response_type(&self) -> ResponseType[src]

Gets the default ResponseType, which is used for any responses that have not had their Content-Type overriden with response_type.

Example

use rocket_lamb::{RocketExt, ResponseType};

let builder = rocket::ignite().lambda();
assert_eq!(builder.get_default_response_type(), ResponseType::Auto);
assert_eq!(builder.get_response_type("text/plain"), ResponseType::Auto);

pub fn default_response_type(self, response_type: ResponseType) -> Self[src]

Sets the default ResponseType, which is used for any responses that have not had their Content-Type overriden with response_type.

Example

use rocket_lamb::{RocketExt, ResponseType};

let builder = rocket::ignite()
    .lambda()
    .default_response_type(ResponseType::Binary);
assert_eq!(builder.get_default_response_type(), ResponseType::Binary);
assert_eq!(builder.get_response_type("text/plain"), ResponseType::Binary);

pub fn get_response_type(&self, content_type: &str) -> ResponseType[src]

Gets the configured ResponseType for responses with the given Content-Type header.

content_type values are treated case-insensitively.

Example

use rocket_lamb::{RocketExt, ResponseType};

let builder = rocket::ignite()
    .lambda()
    .response_type("TEXT/PLAIN", ResponseType::Text);
assert_eq!(builder.get_response_type("text/plain"), ResponseType::Text);
assert_eq!(builder.get_response_type("application/json"), ResponseType::Auto);

pub fn response_type(
    self,
    content_type: &str,
    response_type: ResponseType
) -> Self
[src]

Sets the ResponseType for responses with the given Content-Type header.

content_type values are treated case-insensitively.

Example

use rocket_lamb::{RocketExt, ResponseType};

let builder = rocket::ignite()
    .lambda()
    .response_type("TEXT/PLAIN", ResponseType::Text);
assert_eq!(builder.get_response_type("text/plain"), ResponseType::Text);
assert_eq!(builder.get_response_type("application/json"), ResponseType::Auto);

pub fn base_path_behaviour(self, setting: BasePathBehaviour) -> Self[src]

Determines whether the API Gateway base path is included in the URL processed by Rocket. The default is RemountAndInclude.

When calling the API using the default API Gateway URL e.g. {api-id}.execute-api.{region}.amazonaws.com/{stage}/, the base path will be /{stage}. When calling the API using an API Gateway custom domain, a base path may be configured on the custom domain.

This has no effect for Application Load Balancer requests, as these will never have a base path.

The possible values are:

  • RemountAndInclude - Includes the base bath in the URL. The first request received will be used to determine the base path, and all mounted routes will be cloned and re-mounted at the base path.
  • Include - Includes the base bath in the URL. You must ensure that the Rocket's routes have been mounted at the expected base path.
  • Exclude - Excludes the base bath from the URL. The URL processed by Rocket may not match the full path of the original client, which may cause absolute URLs in responses (e.g. in the Location response header for redirects) to not behave as expected.

Example

use rocket_lamb::{BasePathBehaviour, RocketExt};

let builder = rocket::ignite()
    .lambda()
    .base_path_behaviour(BasePathBehaviour::Exclude);

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Typeable for T where
    T: Any

fn get_type(&self) -> TypeId

Get the TypeId of this object.

impl<T> IntoCollection<T> for T

impl<T, I> AsResult<T, I> for T where
    I: Input, 

impl<T> Erased for T