live video streaming server in golang
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

33 lines
768 B

package dashboard
import (
"log"
"net/http"
"github.com/gorilla/mux"
"github.com/markbates/pkger"
)
// DashboardHandler expose dashboard routes
type DashboardHandler struct {
Assets *pkger.Dir
}
// Append add dashboard routes on a router
func (g DashboardHandler) Append(router *mux.Router) {
if g.Assets == nil {
log.Printf("No assets for dashboard")
return
}
// Expose dashboard
router.Methods(http.MethodGet).
Path("/").
HandlerFunc(func(response http.ResponseWriter, request *http.Request) {
http.Redirect(response, request, request.Header.Get("X-Forwarded-Prefix")+"/dashboard/", http.StatusFound)
})
router.Methods(http.MethodGet).
PathPrefix("/dashboard/").
Handler(http.StripPrefix("/dashboard/", http.FileServer(g.Assets)))
}