mirror of
https://github.com/restic/rest-server.git
synced 2025-10-19 15:43:21 +00:00
Allow multiple repositories
This commit is contained in:
parent
755cf10659
commit
f14b15ee31
2 changed files with 42 additions and 10 deletions
21
main.go
21
main.go
|
@ -20,16 +20,37 @@ var (
|
|||
debug = flag.Bool("debug", false, "output debug messages")
|
||||
)
|
||||
|
||||
func debugHandler(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(
|
||||
func(w http.ResponseWriter, r *http.Request) {
|
||||
log.Printf("%s %s", r.Method, r.URL)
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
}
|
||||
|
||||
func setupMux() *goji.Mux {
|
||||
mux := goji.NewMux()
|
||||
|
||||
if *debug {
|
||||
mux.Use(debugHandler)
|
||||
}
|
||||
|
||||
mux.HandleFunc(pat.Head("/config"), CheckConfig)
|
||||
mux.HandleFunc(pat.Head("/:repo/config"), CheckConfig)
|
||||
mux.HandleFunc(pat.Get("/config"), GetConfig)
|
||||
mux.HandleFunc(pat.Get("/:repo/config"), GetConfig)
|
||||
mux.HandleFunc(pat.Post("/config"), SaveConfig)
|
||||
mux.HandleFunc(pat.Post("/:repo/config"), SaveConfig)
|
||||
mux.HandleFunc(pat.Get("/:type/"), ListBlobs)
|
||||
mux.HandleFunc(pat.Get("/:repo/:type/"), ListBlobs)
|
||||
mux.HandleFunc(pat.Head("/:type/:name"), CheckBlob)
|
||||
mux.HandleFunc(pat.Head("/:repo/:type/:name"), CheckBlob)
|
||||
mux.HandleFunc(pat.Get("/:type/:name"), GetBlob)
|
||||
mux.HandleFunc(pat.Get("/:repo/:type/:name"), GetBlob)
|
||||
mux.HandleFunc(pat.Post("/:type/:name"), SaveBlob)
|
||||
mux.HandleFunc(pat.Post("/:repo/:type/:name"), SaveBlob)
|
||||
mux.HandleFunc(pat.Delete("/:type/:name"), DeleteBlob)
|
||||
mux.HandleFunc(pat.Delete("/:repo/:type/:name"), DeleteBlob)
|
||||
|
||||
return mux
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue