Function lib::run_aws_req [−][src]
pub async fn run_aws_req<C, Q, M, S>(
req: Request,
opts: Options<C, Q, M, S>
) -> Result<Response<String>, AwsError> where
C: Any + Send + Sync + Clone,
Q: Clone + ObjectType + 'static,
M: Clone + ObjectType + 'static,
S: Clone + SubscriptionType + 'static,
Expand description
Runs a request for AWS Lambda or its derivatives (e.g. Netlify). This just takes the entire Lambda request and does all the processing for you, but it’s really just a wrapper around run_serverless_req. You should use this function in your Lambda handler.
Example
use diana::{ create_handler, run_aws_req, run_lambda, AuthCheckBlockState, AwsError, IntoLambdaResponse, LambdaCtx, LambdaRequest, OptionsBuilder, }; #[tokio::main] async fn main() -> Result<(), AwsError> { run_lambda(create_handler(graphql)).await?; Ok(()) } async fn graphql(req: LambdaRequest, _: LambdaCtx) -> Result<impl IntoLambdaResponse, AwsError> { let opts = OptionsBuilder::new() .ctx(Context { pool: DbPool::default(), }) .subscriptions_server_hostname("http://subscriptions-server") .subscriptions_server_port("6000") .subscriptions_server_endpoint("/graphql") .jwt_to_connect_to_subscriptions_server("blah") .auth_block_state(AuthCheckBlockState::AllowAll) .jwt_secret("blah") .schema(Query {}, Mutation {}, Subscription {}) // Endpoints are set up as `/graphql` and `/graphiql` automatically .finish() .expect("Options building failed!"); let res = run_aws_req(req, opts).await?; Ok(res) }