Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added middleware code to all frameworks #252

Closed
wants to merge 2 commits into from

Conversation

LrsK
Copy link
Contributor

@LrsK LrsK commented Jun 9, 2024

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

Problem/Feature

This PR contains code to add middleware wiring for all frameworks, including example middleware based on the documentation for the respective framework.

Description of Changes:

  • Added middleware file, in server package
  • Added Middleware renderer to Templater interface
  • Middleware example and use in router is included by default in all frameworks

Checklist

  • I have self-reviewed the changes being requested
  • [] I have updated the documentation (if applicable)

@briancbarrow
Copy link
Collaborator

Hey @LrsK, thanks for making a PR. We discussed it and we like the idea of adding basic middleware to all frameworks. One thing we'd like to see is consistency across the implementations of middleware. We are thinking you could add a simple logging middleware to everything.

Echo already has their own logging middleware that logs info about the request, so maybe it can be something similar to that.

What do you think?

@LrsK
Copy link
Contributor Author

LrsK commented Jun 9, 2024

That sounds good. I can make a middleware called Logger or something, which would also follow the naming of Echo's logging middleware. I will just use the log/slog package in the standard library and log something simple.

This can replace the DummyMiddleware which was meant as an example that follows the docs from each framework.

@briancbarrow
Copy link
Collaborator

That sounds good. I can make a middleware called Logger or something, which would also follow the naming of Echo's logging middleware. I will just use the log/slog package in the standard library and log something simple.

This can replace the DummyMiddleware which was meant as an example that follows the docs from each framework.

That sounds great!

@Ujstor
Copy link
Collaborator

Ujstor commented Oct 16, 2024

@LrsK Sorry for the long, long delay. New features have been coming in, and there wasn't a clear picture of how to incorporate the middleware part into the codebase. Should we go with a simple implementation as it is, or something more complex.

Some frameworks, like Chi and Gin, already have logger middleware, which could cause conflicts. However, the more important part is ticket #253 —if this is incorporated correctly, we'll need a more complex, prod ready middleware implementation.

For now, I'm closing the PR, and I'll tag you once I open a middleware issue.

@Ujstor Ujstor closed this Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants