From c1b5f61b645eef8998ac6792ff598531e3b350e0 Mon Sep 17 00:00:00 2001 From: stephen mcquay Date: Thu, 11 Feb 2016 12:12:13 -0800 Subject: [PATCH] stubbed out supported methods on / --- server.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/server.go b/server.go index 0581441..76f52d2 100644 --- a/server.go +++ b/server.go @@ -1,15 +1,25 @@ package vain -import "net/http" +import ( + "fmt" + "net/http" +) type Server struct { } -func NewServer(sm *http.ServeMux) *Server { - s := &Server{} - addRoutes(sm, s) - return s +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) + } } -func addRoutes(sm *http.ServeMux, s *Server) { +func NewServer(sm *http.ServeMux) *Server { + s := &Server{} + sm.Handle("/", s) + return s }