Implementing AWS API Gateway from Scratch: Create API Instance

Internals of AWS API Gateway (Partial) Background AWS API Gateway is compromised of an API instance creator and a running instance. The running instance is created when the user hit 'Create API' button in the AWS Console. Once the instance is created, AWS API Gateway provides a URL that we can hit. If we hit it immediately it will return a 404. So the next step is to configure the running instance to handle requests....

October 29, 2022 · Sam E.

AWS API Gateway Routing Incoming Requests: Select Route

Problem: When a request comes in to AWS Api Gateway, it finds the stage and forward the request to it. Then, the stage finds the route and calls its target. In this post, we will explore how the stage selects the route. According to AWS API Gateway documentation, https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-routes.html , selecting routes happens with this priority: Full match for a route and method. Match for a route and method with a greedy path variable ({proxy+})....

October 16, 2022 · Sam E.

Extracting Parameters from Request Path

Problem: In most web frameworks we can define a request handler with app.get('/items/{id}') and item will get passed in to the function as a parameter. We see it and use it every day. But, have you ever thought how its done? Lets find out! Example in FastAPI # test.py from fastapi import FastAPI app = FastAPI() @app.get("/items/{id}") def get_item(id): return {"id": id} Run it with this command: # install dependencies if you have't already pip install fastapi uvicorn # Run it uvicorn test:app --reload and call it:...

October 15, 2022 · Sam E.

Python: Organize Files for Import with Symlinks

Problem: I have a bunch python build scripts, all named bob.py. They are scattered all around a mono repo. I want to be able to import from one another and be treated as bobs package/namespace. For example, I have the following 2 files: projects/a/bob.py projects/b/bob.py From a/bob.py I want to be able to import b/bob.py like so: # a/bob.py import bobs.b.bob as b # use b ... Solution: # loader....

October 7, 2022 · Sam E.