From d0a021660294f76937dd2b7b20bb5a33986e6112 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Thu, 9 Apr 2015 10:08:22 -0600 Subject: [PATCH] Added flag to disable http/2 support (still enabled by default) --- main.go | 7 ++++++- server/server.go | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index f2fd08aa..6d9945a4 100644 --- a/main.go +++ b/main.go @@ -9,10 +9,14 @@ import ( "github.com/mholt/caddy/server" ) -var conf string +var ( + conf string + http2 bool +) func init() { flag.StringVar(&conf, "conf", server.DefaultConfigFile, "the configuration file to use") + flag.BoolVar(&http2, "http2", true, "enable HTTP/2 support") // flag temporary until http2 merged into std lib } func main() { @@ -34,6 +38,7 @@ func main() { if err != nil { log.Fatal(err) } + s.HTTP2 = http2 wg.Add(1) go func(s *server.Server) { defer wg.Done() diff --git a/server/server.go b/server/server.go index 963264b0..0be94525 100644 --- a/server/server.go +++ b/server/server.go @@ -26,6 +26,7 @@ var servers = make(map[string]*Server) // Server represents an instance of a server, which serves // static content at a particular address (host and port). type Server struct { + HTTP2 bool // temporary while http2 is not in std lib (TODO: remove flag when part of std lib) config config.Config fileServer middleware.Handler stack middleware.Handler @@ -83,8 +84,10 @@ func (s *Server) Serve() error { Handler: s, } - // TODO: This call may not be necessary after HTTP/2 is merged into std lib - http2.ConfigureServer(server, nil) + if s.HTTP2 { + // TODO: This call may not be necessary after HTTP/2 is merged into std lib + http2.ConfigureServer(server, nil) + } // Execute shutdown commands on exit go func() {