Review and clean vanity

git-svn-id: file:///srv/svn/repo/toyohime/trunk@21 922d331f-388e-da47-97a9-ad700dc0b8b9
This commit is contained in:
kare.nuorteva 2016-12-11 22:52:00 +00:00
parent 6ca3e72fb1
commit 05892d509d
2 changed files with 9 additions and 10 deletions

View File

@ -48,8 +48,8 @@ func NewServer(domain string, config map[Path]Package) *Server {
func (s Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "text/html; charset=utf-8")
if r.Method != "GET" {
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
if r.Method != http.MethodGet {
http.Error(w, http.StatusText(http.StatusMethodNotAllowed), http.StatusMethodNotAllowed)
return
}

View File

@ -28,13 +28,13 @@ func TestHTTPMethodsSupport(t *testing.T) {
method string
status int
}{
{"GET", 200},
{"HEAD", 405},
{"POST", 405},
{"PUT", 405},
{"DELETE", 405},
{"TRACE", 405},
{"OPTIONS", 405},
{http.MethodGet, http.StatusOK},
{http.MethodHead, http.StatusMethodNotAllowed},
{http.MethodPost, http.StatusMethodNotAllowed},
{http.MethodPut, http.StatusMethodNotAllowed},
{http.MethodDelete, http.StatusMethodNotAllowed},
{http.MethodTrace, http.StatusMethodNotAllowed},
{http.MethodOptions, http.StatusMethodNotAllowed},
}
for _, test := range tests {
req, err := http.NewRequest(test.method, "/gist?go-get=1", nil)
@ -168,6 +168,5 @@ func TestBrowserGoDoc(t *testing.T) {
if contentType != expected {
t.Fatalf("Expecting content type '%v', but got '%v'", expected, contentType)
}
}
}