Documentation
¶
Index ¶
- Constants
- Variables
- func Bind(r *http.Request, target interface{}) error
- func GetRequestID(ctx context.Context) string
- func Metrics(registry *prometheus.Registry) func(http.Handler) http.Handler
- func NegotiateContentType(acceptHeader string, offeredContentTypes []string, defaultOffer string) string
- func Render(w http.ResponseWriter, r *http.Request, v interface{})
- func RenderWithStatusCode(w http.ResponseWriter, r *http.Request, statusCode int, v interface{})
- func RequestID(next http.Handler) http.Handler
- func RequestLogger(next http.Handler) http.Handler
Constants ¶
const ErrTagHTTPStatusCodeKey = "StatusCode"
const ErrTypeHTTPPublic = "Public"
const RequestIDHeaderName = "X-Request-ID"
const RequestIDKey ctxKeyRequestID = 0
RequestIDKey is the key that holds the unique request ID in a request context.
Variables ¶
var (
OfferedContentTypes = []string{
"application/x-yaml",
"application/yaml",
"text/yaml",
"application/json",
"text/json",
"application/xml",
"text/xml",
"text/html",
"text/plain",
}
)
Functions ¶
func GetRequestID ¶
func NegotiateContentType ¶
func NegotiateContentType(acceptHeader string, offeredContentTypes []string, defaultOffer string) string
NegotiateContentType returns the best offered content type for the request's Accept header. If two offers match with equal weight, then the more specific offer is preferred. For example, text/* trumps */*. If two offers match with equal weight and specificity, then the offer earlier in the list is preferred. If no offers match, then defaultOffer is returned.
func RenderWithStatusCode ¶
func RenderWithStatusCode(w http.ResponseWriter, r *http.Request, statusCode int, v interface{})
Types ¶
This section is empty.