Skip to content

Accessing RequestContext #443

Description

@niroam

Hi,

A question not an issue - still learning rust as well so bear with me :)

could someone help understand how the Object models work with the request types

I am calling my handler function like this

lambda_http::run(service_fn(|event: Request| process_request(event))).await?;

so passing in an event object of type Request, the event is coming from an APIGW Lambda Proxy Integration

within the handler if i look at the request context using event.request_context() -> which returns the object type RequestContext

debug!("TEST### {:?}", event.request_context());

i can see this

ApiGatewayV1("ApiGatewayProxyRequestContext"{
   "account_id":"Some(""1231321232123"")",
   "resource_id":"Some(""xxxxx"")",
   "operation_name":"None",
   "stage":"Some(""dev"")",
   "domain_name":"Some(""11111111111.amazonaws.com"")",
   "domain_prefix":"Some(""dddddd"")",
   "request_id":"Some(""xxxxxxxxxx"")",
   "protocol":"Some(""HTTP/1.1"")",
   "identity":"ApiGatewayRequestIdentity"{
      "cognito_identity_pool_id":"None",
      "account_id":"None",
      "cognito_identity_id":"None",
      "caller":"None",
      "api_key":"None",
      "api_key_id":"None",
      "access_key":"None",
      "source_ip":"Some(""1111111111"")",
      "cognito_authentication_type":"None",
      "cognito_authentication_provider":"None",
      "user_arn":"None",
      "user_agent":"Some(""PostmanRuntime/7.28.4"")",
      "user":"None"
   },
   "resource_path":"Some(""/ledger/{id}"")",
   "authorizer":{
      "accesskey":"String(""hhhhhhhh"")",
      "secretkey":"String(""lllllll"")",
      "tenantId":"String(""1234567xyz"")",
      "integrationLatency":Number(370),
      "principalId":"String(""User|bbbb.am"")",
      "sessiontoken":"String(""hhhhhhhhh"")",
      "userName":"String(""niro.am"")"
   },
   "http_method":"GET",
   "request_time":"Some(""09/Mar/2022:20:20:45 +0000"")",
   "request_time_epoch":1646857245706,
   "apiid":"Some(""hhhhhhhh"")"
})

Can anyone point me in the right direction on how you access the data inside the ApiGatewayProxyRequestContext object ? The generic RequestContext object itself does not seem to have any way to get the data ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions