https://github.com/ifnotnil/httpx
golang http compress, log and utils
https://github.com/ifnotnil/httpx
go golang http utils
Last synced: 3 months ago
JSON representation
golang http compress, log and utils
- Host: GitHub
- URL: https://github.com/ifnotnil/httpx
- Owner: ifnotnil
- License: mit
- Created: 2025-02-02T21:33:38.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-16T06:31:38.000Z (12 months ago)
- Last Synced: 2025-04-16T08:09:33.943Z (12 months ago)
- Topics: go, golang, http, utils
- Language: Go
- Homepage:
- Size: 430 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# httpx
[](https://github.com/ifnotnil/httpx/actions/workflows/ci.yml)
[](https://codecov.io/gh/ifnotnil/httpx)[](https://goreportcard.com/report/github.com/ifnotnit/httpx)
[](https://pkg.go.dev/github.com/ifnotnit/httpx)
## httpx/compress
Http middleware (inbound - todo) and RoundTripper (outbound) that handles compression (br.deflate,gzip,zstd).
## httpx/log
Http middleware (inbound) and RoundTripper (outbound) using slog.
### Inbound Logger (http middleware)
Inbound logger middleware (http handler) can be initialized with
#### A logger ([WithLogger](log/logger.go#L7))
The logger that is set with this function is the logger will be used to log the traffic. If no logger is set the `slog.Default()` will be used.
#### A level ([WithLogInLevel](log/logger.go#L11))
The level that is set with this function is the log level in which the middleware will log the traffic.
Default value: `slog.LevelDebug`.
#### A log mode ([WithMode](log/logger.go#L15))
The log mode can take two values `Drain` and `Tee`.
* When `Drain` is selected the body of the income request is read entirely upon receiving and a copy of the body will be passed to the next http handlers.
* When `Tee` is selected a tee reader wraps incoming request's body and then the request is passed to the next http handlers. The request body will be read when (and only) the next (or final) http handlers, read it.
Default value: `Drain`.
#### A log policy ([WithLogPolicy](log/logger.go#L19))
The log policy can indicate conditions