Skip to content

Commit

Permalink
Expose HTTP/3 for API
Browse files Browse the repository at this point in the history
  • Loading branch information
taoso committed Apr 14, 2024
1 parent 6b1cb2e commit 5e64bca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/zns/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ If not free, you should set the following environment variables:
if lnH3 != nil {
p := lnH3.LocalAddr().(*net.UDPAddr).Port
h.AltSvc = fmt.Sprintf(`h3=":%d"`, p)
fmt.Println(h.AltSvc)
th.AltSvc = h.AltSvc

h3 := http3.Server{Handler: mux, TLSConfig: tlsCfg}
go h3.Serve(lnH3)
Expand Down
5 changes: 5 additions & 0 deletions ticket.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,14 @@ type TicketHandler struct {
MBpCNY int
Pay Pay
Repo TicketRepo
AltSvc string
}

func (h *TicketHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if h.AltSvc != "" {
w.Header().Set("Alt-Svc", h.AltSvc)
}

if r.Method == http.MethodGet {
token := r.PathValue("token")
ts, err := h.Repo.List(token, 10)
Expand Down

0 comments on commit 5e64bca

Please sign in to comment.