#What's up Chi Gang. I have a question about middlewares

14 messages · Page 1 of 1 (latest)

placid haven
#

When building API using chi, which middleware are you guys using for logging, rate limiting, jwt, and stuff like that?
do you just use the middleware.logger and the httprate ?

I was trying to implement these from scratch but it's taking me so long to get it to a level where I am confident enough to push it into production. And then I realized, chi has all these other packages and middlewares.

Do you use these or do you guys use something else?
https://github.com/go-chi/cors
https://github.com/go-chi/httplog

https://github.com/go-chi/jwtauth

https://github.com/go-chi/httprate
https://github.com/go-chi/httprate-redis

https://github.com/go-chi/docgen
https://github.com/go-chi/metrics

GitHub

CORS net/http middleware for Go. Contribute to go-chi/cors development by creating an account on GitHub.

GitHub

Go HTTP request logger with structured logging capabilities built on "log/slog" package - go-chi/httplog

GitHub

JWT authentication middleware for Go HTTP services - go-chi/jwtauth

GitHub

net/http rate limiter middleware. Contribute to go-chi/httprate development by creating an account on GitHub.

GitHub

httprate.LimitCounter implementation with Redis backend - go-chi/httprate-redis

#

What's up Chi Gang. I have a question about middlewares

rough maple
placid haven
#

do you use the normal logger middleware or the httplog one?

#

you cannot control log level for the the normal logger middlware,

The httplog use go's "slog" and while you can control log level with it, I kinda don't like how it's formatted as key/value

placid haven
#

fair... stdlib enjoyer

proud hemlock
placid haven
#

Probably just personal preference, I haven't been doing this long enough to see why it needs to be in that format. And I'm used to just seeing plain TIME METHOD CODE MESSAGE DURATION values without keys...

placid haven
proud hemlock
#

So if you leave the message static, it becomes possible for you to find all occurrences of it and find out each detail, or find all log entries with a specific attribute, making it possible for you to find log entries associated with the thing you're investigating.

#

There's nothing worse than searching through a log that is not structured.

storm heath
#

well there is one thing worse; no logs to look at