mirror of
https://github.com/umputun/reproxy.git
synced 2024-11-30 08:16:56 +02:00
22 lines
596 B
Go
22 lines
596 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=\"%s\", date=\"%s\"", version, date.Format(time.RFC3339))
|
|
w.Header().Set("Deprecation", headerVal)
|
|
h.ServeHTTP(w, r)
|
|
}
|
|
return http.HandlerFunc(fn)
|
|
}
|
|
return f
|
|
}
|