Documentation
¶
Overview ¶
Package sunset implements a middleware around sunset HTTP headers.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMiddleware ¶
NewMiddleware returns a new middleware that adds Sunset HTTP headers, as per RFC 8594.
Example ¶
package main
import (
"net/http"
"time"
"codeberg.org/kema/kmicro/pkg/http/middleware/sunset"
"codeberg.org/kema/kmicro/pkg/http/router"
)
func main() {
r := router.New()
r.Use(sunset.NewMiddleware(
sunset.WithSunset(time.Now().UTC()),
))
// curl -v localhost:8080/
r.HandleFunc("GET /", func(w http.ResponseWriter, _ *http.Request) {
_, _ = w.Write([]byte("Hello, World!"))
})
_ = http.ListenAndServe("[::]:8080", r.Compile())
}
Output:
Types ¶
Click to show internal directories.
Click to hide internal directories.