This is a simple API built with FastAPI that logs the details of every incoming HTTP request. It is designed to be deployed as a serverless container on Google Cloud Run.
- Catch-all Endpoint: Captures all requests (GET, POST, PUT, DELETE, etc.) to any URL path.
- Structured Logging: Logs the following information for each request in JSON format to standard output:
- URL
- HTTP Method
- Source IP Address (
X-Forwarded-Forheader or remote address) - Request Payload (Body)
- Request Headers
- Containerized: Includes a
Dockerfilefor easy building and deployment. - Fast Dependencies: Uses
uvfor fast Python package management.
The application uses a FastAPI middleware to intercept every request before it hits the endpoint. The middleware extracts the relevant information, formats it into a JSON object, and prints it to the console. Cloud Run automatically collects these logs, allowing you to view them in the Google Cloud Logging interface.
The main endpoint simply returns a 200 OK response with the message "Request logged".
(Instructions will be provided separately)