gosimplenpm/app.go

29 lines
695 B
Go
Raw Permalink Normal View History

package main
import (
"log"
"github.com/gorilla/mux"
"gosimplenpm/handler"
)
type application struct {
logger *log.Logger
}
func (app *application) Routes() *mux.Router {
m := mux.NewRouter()
// main handler
m.HandleFunc("/{name}", handler.Get).Methods("GET")
m.HandleFunc("/{name}", handler.Publish).Methods("PUT")
// tar handlers
m.HandleFunc("/{name}/-/{tar}", handler.Tar).Methods("GET")
// tag handlers
m.HandleFunc("/-/package/{name}/dist-tags/{tag}", handler.DistTagDelete).Methods("DELETE")
m.HandleFunc("/-/package/{name}/dist-tags/{tag}", handler.DistTagPut).Methods("PUT")
m.HandleFunc("/-/package/{name}/dist-tags", handler.DistTagGet).Methods("GET")
return m
}