ctxheaders

package
v0.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Middleware

func Middleware(next http.Handler, opts ...Option) http.Handler

Middleware is a server-side http ware for set headers in tags and/or in context.

Example

mux := http.NewServeMux() mux.HandleFunc("/", handler)

httpServer := &http.Server{
    Addr:    "0.0.0.0:8080",
    Handler: http_ctxtags.Middleware("http")(
        ctxheaders.Middleware(
            mux,
            ctxheaders.HeadersToContext(map[string]string{
                "X-Site-ID": "x-site-id",
            }),
        ),
    ),
}.

Types

type Option

type Option func(*options)

func HeadersToContext

func HeadersToContext(v map[string]string) Option

HeadersToContext is a map relationships between headers and context.

func HeadersToTags

func HeadersToTags(v []string) Option

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL