diff --git a/handlers/index.go b/handlers/index.go new file mode 100644 index 0000000..76e85d5 --- /dev/null +++ b/handlers/index.go @@ -0,0 +1,32 @@ +package handlers + +import ( + "net/http" +) + +// Index handler. +type Index struct { +} + +// NewIndex returns new Index handler. +func NewIndex() *Index { + return &Index{} +} + +// ServeHTTP handles requests on incoming connections. +func (i *Index) ServeHTTP(w http.ResponseWriter, r *http.Request) { + if r.Method != "GET" && r.Method != "HEAD" { + http.Error(w, "405 Method Not Allowed", http.StatusMethodNotAllowed) + return + } + + w.Write([]byte(` +