mirror of
https://github.com/restic/rest-server.git
synced 2025-10-19 15:43:21 +00:00
added handlers and context
This commit is contained in:
parent
04e8c1e148
commit
2fb76f3f8d
4 changed files with 197 additions and 130 deletions
|
@ -14,22 +14,22 @@ func TestRouter(t *testing.T) {
|
|||
router := NewRouter()
|
||||
|
||||
getConfig := []byte("GET /config")
|
||||
router.Get("/config", func(w http.ResponseWriter, r *http.Request) {
|
||||
router.GetFunc("/config", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write(getConfig)
|
||||
})
|
||||
|
||||
postConfig := []byte("POST /config")
|
||||
router.Post("/config", func(w http.ResponseWriter, r *http.Request) {
|
||||
router.PostFunc("/config", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write(postConfig)
|
||||
})
|
||||
|
||||
getBlobs := []byte("GET /blobs/")
|
||||
router.Get("/blobs/", func(w http.ResponseWriter, r *http.Request) {
|
||||
router.GetFunc("/blobs/", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write(getBlobs)
|
||||
})
|
||||
|
||||
getBlob := []byte("GET /blobs/:sha")
|
||||
router.Get("/blobs/:sha", func(w http.ResponseWriter, r *http.Request) {
|
||||
router.GetFunc("/blobs/:sha", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write(getBlob)
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue