aws / chalice

Python Serverless Microframework for AWS
Apache License 2.0
10.61k stars 1.01k forks source link

Is it possible to update API gateway routes ? #2038

Open mangled-data opened 1 year ago

mangled-data commented 1 year ago

I would like to use chalice to setup API gateway. I start with a simple route

def index():
    return {'hello': 'world'}

@app.route('/customer1')
def index():
    return {'who': 'customer1'}

@app.route('/customer2')
def index():
    return {'who': 'customer2'}

Now customer3 arrives few days later. Is there a way to update without shutting down and restarting all the resources. Thanks for pointers as it'd help me decide if chalice is the right way to go. I just tried custom domain and chalice was such a breeze!! Fantastic productive framework!

sean-hernon commented 1 year ago

The normal way to achieve this is by separating the type of resource from the identifier. So /customer/{id} for example.

Chalice lets you do something like this.

@app.route('/customer/{id}', methods=['GET'])
def get_customer(id):
    return {'who': f'customer{id}'}