git.sr.ht/~pingoo/stdx@v0.0.0-20240218134121-094174641f6e/httpx/middlewarex/server_header.go (about)

     1  package middlewarex
     2  
     3  import (
     4  	"net/http"
     5  
     6  	"git.sr.ht/~pingoo/stdx/httpx"
     7  )
     8  
     9  func SetServerHeader(server string) func(next http.Handler) http.Handler {
    10  	return func(next http.Handler) http.Handler {
    11  		fn := func(w http.ResponseWriter, req *http.Request) {
    12  			w.Header().Set(httpx.HeaderServer, server)
    13  			next.ServeHTTP(w, req)
    14  		}
    15  		return http.HandlerFunc(fn)
    16  	}
    17  }