-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathserver_test.go
34 lines (30 loc) · 870 Bytes
/
server_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package htest
import (
"github.com/go-chi/chi"
"io"
"net/http"
)
var (
Mux *chi.Mux
)
func init() {
Mux = chi.NewRouter()
Mux.Get("/name", NameHandler)
Mux.Get("/client/get", NameHandler)
Mux.Trace("/client/trace", NameHandler)
Mux.Delete("/client/delete", NameHandler)
Mux.Connect("/client/connect", NameHandler)
Mux.Options("/client/options", NameHandler)
Mux.Head("/client/head", NameHandler)
Mux.Post("/client/post", ClientDataHandler)
Mux.Put("/client/put", ClientDataHandler)
Mux.Patch("/client/patch", ClientDataHandler)
Mux.Post("/client/patch", ClientDataHandler)
Mux.Get("/request/header", HeaderHandler)
Mux.Get("/request/cookie", CookieHandler)
Mux.Get("/body/user", UserDataHandler)
Mux.Get("/xml_body/user", UserDataXMLHandler)
}
func NameHandler(w http.ResponseWriter, req *http.Request) {
io.WriteString(w, `{"name": "hexi"}`)
}