I’m creating an API that parses a name into its separate parts. I want to require an API key on AWS. The function in my flask app looks like this:
# app.py
@app.route('/names/<name>', methods=['GET'])
def convert_name(name):
# do stuff
I noticed that this works to return a valid API response, but does not set the API to private.
# serverless.yml
functions:
app:
handler: wsgi_handler.handler
events:
- http: 'GET /names/{proxy+}'
private: true
So I changed the file to this:
# serverless.yml
functions:
app:
handler: wsgi_handler.handler
events:
- http:
path: names/{proxy+}
method: get
private: true
This sets the route to private like I want, but now the routing is messed up and all I get is a 404 when sending a valid input such as /names/John M. Glenn.
Any idea what I am doing wrong here?