Request validation on path in Api Gateway

629 Views Asked by At

I have an API gateway which is a kind of url shortner, it accepts all the get requests and return the long url associated with that short url path. example

input GET => xxx.com/abc

return => aaa.com/blablablabla

I want to implement some validation on this so that I don't get unnecessary junk requests based on path with a regular expression

suppose path should start with "a" in incoming request xxx.com/abc

How can I do that via api gateway request validator, any help

1

There are 1 best solutions below

1
On

You better try Lambda Authorizer for requests validator.

Your Lambda function will have 2 main tasks

  • Validate the URL of the request.
  • Validate the request's Auth header.

Lambda supports various of languages: Python3, Go, Java, Node.js ... so you are freely to use ReGex to filter your requests.

Reference: https://docs.aws.amazon.com/apigateway/latest/developerguide/configure-api-gateway-lambda-authorization-with-console.html