Skip to content

Commit 7eabeb7

Browse files
committed
add ParseForm() in middleware
1 parent dd98c72 commit 7eabeb7

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ The "app" config section (the structure is located in [/app/config.go](https://g
4949

5050
Configuration values can be automatically taken from environment variables using the `my_key: {{ENV_VARIABLE}}` syntax. This approach combines the best of both worlds: setting parameters via env variables while keeping them organized in a human-readable, structured YAML format.
5151

52+
## Considerations and gotchas
53+
54+
- you don't need to call `r.ParseForm()` in your handlers: the middleware does it. Just use `r.Form["param"]`.
55+
5256
## Roadmap
5357

5458
- [x] Basic blocks

httpserver/middleware.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ func panicLoggerMiddleware(next http.Handler, logger log.MetaLogger) http.Handle
7575

7676
func instrumentationMiddleware(handler HandlerWithResult, logger log.MetaLogger, metrics *serviceMetrics, service, endpoint string) http.HandlerFunc {
7777
return func(w http.ResponseWriter, r *http.Request) {
78+
_ = r.ParseForm()
79+
7880
// get real remote address
7981
remoteAddr := r.RemoteAddr
8082
if x, found := r.Header["X-Forwarded-For"]; found {

0 commit comments

Comments
 (0)