Browse Source

fix up routes

Brett Langdon 9 years ago
parent
commit
c40bbe1f7f
No known key found for this signature in database GPG Key ID: A2ECAB73CE12147F
1 changed files with 17 additions and 3 deletions
  1. +17
    -3
      router.go

+ 17
- 3
router.go View File

@ -156,13 +156,27 @@ func (r *Router) logRequests(h http.Handler) http.Handler {
func (r *Router) Handler() http.Handler { func (r *Router) Handler() http.Handler {
var h *mux.Router var h *mux.Router
h = mux.NewRouter()
h.HandleFunc("/", r.handleIndex).Methods("GET")
h = mux.NewRouter().StrictSlash(false)
// Static favicon
h.HandleFunc("/favicon.ico", r.handleFavicon).Methods("GET") h.HandleFunc("/favicon.ico", r.handleFavicon).Methods("GET")
// All links, useful for non-owner/repo specific --find-links
h.HandleFunc("/", r.handleIndex).Methods("GET")
// Simple index
h.HandleFunc("/simple", r.handleSimple).Methods("GET") h.HandleFunc("/simple", r.handleSimple).Methods("GET")
h.HandleFunc("/simple/", r.handleSimple).Methods("GET")
h.HandleFunc("/simple/{repo}", r.handleSimpleProject).Methods("GET")
h.HandleFunc("/simple/{repo}/", r.handleSimpleProject).Methods("GET")
// Owner/repo specific find-links
h.HandleFunc("/{owner}", r.handleOwnerIndex).Methods("GET") h.HandleFunc("/{owner}", r.handleOwnerIndex).Methods("GET")
h.HandleFunc("/{owner}/", r.handleOwnerIndex).Methods("GET")
h.HandleFunc("/{owner}/{repo}", r.handleRepoIndex).Methods("GET") h.HandleFunc("/{owner}/{repo}", r.handleRepoIndex).Methods("GET")
h.HandleFunc("/{owner}/{repo}", r.handleRepoIndex).Methods("GET")
h.HandleFunc("/{owner}/{repo}/", r.handleRepoIndex).Methods("GET")
// Download asset
h.HandleFunc("/{owner}/{repo}/{asset}", r.handleFetchAsset).Methods("GET") h.HandleFunc("/{owner}/{repo}/{asset}", r.handleFetchAsset).Methods("GET")
return r.logRequests(h) return r.logRequests(h)
} }


Loading…
Cancel
Save