...

/

Adding Request Logging via Middleware

Adding Request Logging via Middleware

Learn how to perform request logging via middleware functions in a Deno application.

We'll cover the following...

In this lesson, we’ll use the middleware we created previously and add logic to log what request is being made to the server.

Now that we have the logic to calculate the request timing we’ve built, we’re in a great place to add request logging to our application. The final goal is to have every request that is made to the application logged to the console with its path, HTTP method, and the time it took to answer. We’re looking for something like the following example:

GET http://localhost:8080/api/museums - 65ms

We could, of course, do this individually per request, but since this is something that we want to do cross-application, we’ll add it as a piece of middleware to the Application object.

The middleware we wrote previously requires the handlers (and middleware functions) to run for it to add the response time (it ...