Skip to content
File

Blob: gateway/header.go

go26 lines
1package gateway
2 
3import (
4 "fmt"
5 "net/http"
6 "strings"
7 
8 "go.miragespace.co/specter/spec/cipher"
9)
10 
11func generateAltHeaders(port int) string {
12 alt := []string{}
13 for _, proto := range cipher.H3Protos {
14 alt = append(alt, fmt.Sprintf(`%s=":%d"; ma=86400`, proto, port))
15 }
16 return strings.Join(alt, ", ")
17}
18 
19func (g *Gateway) appendHeaders(h3 bool) func(h http.Header) {
20 return func(h http.Header) {
21 h.Set("server", "specter")
22 h.Set("http3", fmt.Sprintf("%v", h3))
23 h.Set("alt-svc", g.altHeaders)
24 }
25}