Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FileServer ¶
FileServer is a FileServerHandler with the NotFound handler set to http.NotFound.
func FileServerHandler ¶
func FileServerHandler(root string, notFound http.HandlerFunc) http.Handler
FileServerHandler creates a file server that serves files from from a "Root" folder. It will call "NotFound" HandlerFunc if the file cannot be found on the system. In the event where the path is a directory, it will not redirect and instead call "NotFound" HandlerFunc.
Types ¶
type Server ¶
type Server struct { Addr string // TCP address to listen on, ":http" if empty Handler http.Handler // handler to invoke, http.DefaultServeMux if nil Timeout time.Duration // Timeout to wait for shutdown }
Server will create a http.Server from the Go standard library
Example ¶
ExampleServer is an example of how to launch a server If you use docker, [docker stop](https://docs.docker.com/compose/reference/stop/) has a default timeout of 10 seconds, the graceful timeout should be set to expire before then.
s := Server{ Addr: ":8080", Timeout: 5 * time.Second, } log.Println("Starting...") log.Println(s.ListenAndServe())
Output:
func (*Server) ListenAndServe ¶
ListenAndServe mirrors the function from the Go standard library ListenAndServe always returns a non-nil error