Files
remark42/backend/vendor/github.com/go-pkgz/rest/depricattion.go
T
Dmitry VerkhoturovandUmputun 8d42d0714f bump backend dependencies
Also, switch from fork github.com/umputun/go-flags back to original
github.com/jessevdk/go-flags.
2022-01-31 14:24:33 -06:00

22 lines
588 B
Go

package rest
import (
"fmt"
"net/http"
"time"
)
// Deprecation adds a header 'Deprecation: version="version", date="date" header'
// see https://tools.ietf.org/id/draft-dalal-deprecation-header-00.html
func Deprecation(version string, date time.Time) func(http.Handler) http.Handler {
f := func(h http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request) {
headerVal := fmt.Sprintf("version=%q, date=%q", version, date.Format(time.RFC3339))
w.Header().Set("Deprecation", headerVal)
h.ServeHTTP(w, r)
}
return http.HandlerFunc(fn)
}
return f
}