From 6706c9225a8dcb976785bdf2c35eb151d54ac18c Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Tue, 18 Jun 2019 11:13:12 -0600 Subject: Implement templates handler; various minor cleanups and bug fixes --- modules/caddyhttp/server.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'modules/caddyhttp/server.go') diff --git a/modules/caddyhttp/server.go b/modules/caddyhttp/server.go index 3de82f6..61b5631 100644 --- a/modules/caddyhttp/server.go +++ b/modules/caddyhttp/server.go @@ -15,10 +15,10 @@ import ( // Server is an HTTP server. type Server struct { Listen []string `json:"listen,omitempty"` - ReadTimeout caddy.Duration `json:"read_timeout,omitempty"` - ReadHeaderTimeout caddy.Duration `json:"read_header_timeout,omitempty"` - WriteTimeout caddy.Duration `json:"write_timeout,omitempty"` - IdleTimeout caddy.Duration `json:"idle_timeout,omitempty"` + ReadTimeout caddy.Duration `json:"read_timeout,omitempty"` + ReadHeaderTimeout caddy.Duration `json:"read_header_timeout,omitempty"` + WriteTimeout caddy.Duration `json:"write_timeout,omitempty"` + IdleTimeout caddy.Duration `json:"idle_timeout,omitempty"` MaxHeaderBytes int `json:"max_header_bytes,omitempty"` Routes RouteList `json:"routes,omitempty"` Errors *httpErrorConfig `json:"errors,omitempty"` @@ -40,6 +40,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { // set up the context for the request repl := caddy.NewReplacer() ctx := context.WithValue(r.Context(), caddy.ReplacerCtxKey, repl) + ctx = context.WithValue(ctx, ServerCtxKey, s) ctx = context.WithValue(ctx, TableCtxKey, make(map[string]interface{})) // TODO: Implement this r = r.WithContext(ctx) @@ -126,5 +127,7 @@ type httpErrorConfig struct { // the logging configuration first. } -// TableCtxKey is the context key for the request's variable table. +const ServerCtxKey caddy.CtxKey = "server" + +// TableCtxKey is the context key for the request's variable table. TODO: implement this const TableCtxKey caddy.CtxKey = "table" -- cgit v1.2.3