{"modulePath":"github.com/bmbstack/caddy","version":"v0.7.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package server\n\nPackage server implements a configurable, general-purpose web server. It relies on configurations obtained from the adjacent config package and can execute middleware as defined by the adjacent middleware package.\n\n## Functions\n\n```go\nfunc FileServer(root http.FileSystem, hide []string) middleware.Handler\n```\nFileServer is adapted from the one in net/http by the Go authors. Significant modifications have been made.\n\nLicense:\n\nCopyright 2009 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.\n\n```go\nfunc ListenAndServeTLSWithSNI(srv *http.Server, tlsConfigs []TLSConfig) error\n```\nListenAndServeTLSWithSNI serves TLS with Server Name Indication (SNI) support, which allows multiple sites (different hostnames) to be served from the same address. This method is adapted directly from the std lib's net/http ListenAndServeTLS function, which was written by the Go Authors. It has been modified to support multiple certificate/key pairs.\n\n## Types\n\n```go\ntype Config struct {\n\t// The hostname or IP on which to serve\n\tHost string\n\n\t// The host address to bind on - defaults to (virtual) Host if empty\n\tBindHost string\n\n\t// The port to listen on\n\tPort string\n\n\t// The directory from which to serve files\n\tRoot string\n\n\t// HTTPS configuration\n\tTLS TLSConfig\n\n\t// Middleware stack; map of path scope to middleware -- TODO: Support path scope?\n\tMiddleware map[string][]middleware.Middleware\n\n\t// Functions (or methods) to execute at server start; these\n\t// are executed before any parts of the server are configured,\n\t// and the functions are blocking\n\tStartup []func() error\n\n\t// Functions (or methods) to execute when the server quits;\n\t// these are executed in response to SIGINT and are blocking\n\tShutdown []func() error\n\n\t// The path to the configuration file from which this was loaded\n\tConfigFile string\n\n\t// The name of the application\n\tAppName string\n\n\t// The application's version\n\tAppVersion string\n}\n```\nConfig configuration for a single server.\n\n```go\nfunc (c Config) Address() string\n```\nAddress returns the host:port of c as a string.\n\n```go\ntype Server struct {\n\tHTTP2 bool // temporary while http2 is not in std lib (TODO: remove flag when part of std lib)\n\t// contains filtered or unexported fields\n}\n```\nServer represents an instance of a server, which serves static content at a particular address (host and port).\n\n```go\nfunc New(addr string, configs []Config, tls bool) (*Server, error)\n```\nNew creates a new Server which will bind to addr and serve the sites/hosts configured in configs. This function does not start serving.\n\n```go\nfunc (s *Server) Serve() error\n```\nServe starts the server. It blocks until the server quits.\n\n```go\nfunc (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)\n```\nServeHTTP is the entry point for every request to the address that s is bound to. It acts as a multiplexer for the requests hostname as defined in the Host header so that the correct virtualhost (configuration and middleware stack) will handle the request.\n\n```go\ntype TLSConfig struct {\n\tEnabled                  bool\n\tCertificate              string\n\tKey                      string\n\tCiphers                  []uint16\n\tProtocolMinVersion       uint16\n\tProtocolMaxVersion       uint16\n\tPreferServerCipherSuites bool\n\tClientCerts              []string\n}\n```\nTLSConfig describes how TLS should be configured and used, if at all. A certificate and key are both required. The rest is optional.\n\n","path":"github.com/bmbstack/caddy/server","name":"server","synopsis":"Package server implements a configurable, general-purpose web server.","isRedistributable":true}
