stubbed out supported methods on /
This commit is contained in:
parent
158ef57b13
commit
c1b5f61b64
22
server.go
22
server.go
@ -1,15 +1,25 @@
|
|||||||
package vain
|
package vain
|
||||||
|
|
||||||
import "net/http"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServer(sm *http.ServeMux) *Server {
|
func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
s := &Server{}
|
switch req.Method {
|
||||||
addRoutes(sm, s)
|
case "GET":
|
||||||
return s
|
case "POST":
|
||||||
|
case "PATCH":
|
||||||
|
default:
|
||||||
|
http.Error(w, fmt.Sprintf("unsupported method %q; accepted: POST, GET, PATCH", req.Method), http.StatusMethodNotAllowed)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func addRoutes(sm *http.ServeMux, s *Server) {
|
func NewServer(sm *http.ServeMux) *Server {
|
||||||
|
s := &Server{}
|
||||||
|
sm.Handle("/", s)
|
||||||
|
return s
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user