update README and enhance request ID handling

This commit is contained in:
Pedro Pérez 2024-11-23 12:39:12 +01:00
parent 2340bdca11
commit 5183e62271
2 changed files with 3 additions and 2 deletions

View File

@ -6,7 +6,7 @@ todo te será familiar.
## Características ## Características
- Sin dependencias - Sin dependencias ajenas a Google
- Procesamiento y salida de ficheros HTML - Procesamiento y salida de ficheros HTML
- Paginación lista para usar - Paginación lista para usar
- Vinculación entrada formulario y JSON a tipos estructurados. - Vinculación entrada formulario y JSON a tipos estructurados.

3
ron.go
View File

@ -53,6 +53,7 @@ type (
) )
const ( const (
RequestID string = "request_id"
HeaderJSON string = "application/json" HeaderJSON string = "application/json"
HeaderHTML_UTF8 string = "text/html; charset=utf-8" HeaderHTML_UTF8 string = "text/html; charset=utf-8"
HeaderCSS_UTF8 string = "text/css; charset=utf-8" HeaderCSS_UTF8 string = "text/css; charset=utf-8"
@ -166,7 +167,7 @@ func (e *Engine) requestIdMiddleware() Middleware {
if id == "" { if id == "" {
id = fmt.Sprintf("%d", time.Now().UnixNano()) id = fmt.Sprintf("%d", time.Now().UnixNano())
} }
ctx = context.WithValue(ctx, "requestId", id) ctx = context.WithValue(ctx, RequestID, id)
next.ServeHTTP(w, r.WithContext(ctx)) next.ServeHTTP(w, r.WithContext(ctx))
}) })
} }