1
0
forked from sm/vain
vain/server.go

26 lines
433 B
Go
Raw Normal View History

2016-02-11 11:57:16 -08:00
package vain
2016-02-08 00:15:22 -08:00
2016-02-11 12:12:13 -08:00
import (
"fmt"
"net/http"
)
2016-02-08 00:15:22 -08:00
type Server struct {
}
2016-02-11 12:12:13 -08:00
func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {
switch req.Method {
case "GET":
case "POST":
case "PATCH":
default:
http.Error(w, fmt.Sprintf("unsupported method %q; accepted: POST, GET, PATCH", req.Method), http.StatusMethodNotAllowed)
}
}
2016-02-08 00:15:22 -08:00
func NewServer(sm *http.ServeMux) *Server {
s := &Server{}
2016-02-11 12:12:13 -08:00
sm.Handle("/", s)
2016-02-08 00:15:22 -08:00
return s
}