With no testing, and no evidence that we did anything correctly, it appears the has cleaned up the api a little tiny bit
This commit is contained in:
parent
9ebc43e072
commit
b15a05676c
@ -3,6 +3,7 @@ package servlet
|
||||
import (
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"regexp"
|
||||
@ -77,6 +78,12 @@ func (s *VinegarServlet) Start() {
|
||||
|
||||
}
|
||||
|
||||
func (s *VinegarServlet) PrintRoutes() {
|
||||
for _, route := range s.Routes {
|
||||
log.Println(route.Pattern.String())
|
||||
}
|
||||
}
|
||||
|
||||
func SendError(w http.ResponseWriter, code int, msg string) {
|
||||
errorFile := "templates/error.html"
|
||||
errorResp := ErrorResponse{code, msg}
|
||||
|
||||
@ -18,20 +18,24 @@ type (
|
||||
|
||||
func NewImageRoute(servlet *VinegarServlet, urlPattern string, pathlike string, useCache bool) *FileRoute {
|
||||
defaultPrune := strings.Replace(urlPattern, ".*", "", -1)
|
||||
imgRoute := FileRoute{srv: servlet, fileRoot: pathlike, UseCache: useCache}
|
||||
rootRoute := NewServletRoute(urlPattern, createUncompressedFileServletFunction(&imgRoute, defaultPrune, pathlike))
|
||||
imgRoute.VinegarRoute = rootRoute //i *kinda* don't like this pattern
|
||||
return &imgRoute
|
||||
route := FileRoute{srv: servlet, fileRoot: pathlike, UseCache: useCache}
|
||||
rootRoute := NewServletRoute(urlPattern, createUncompressedFileServletFunction(&route, defaultPrune, pathlike))
|
||||
route.VinegarRoute = rootRoute //i *kinda* don't like this pattern
|
||||
|
||||
servlet.AddRoute(route.VinegarRoute)
|
||||
return &route
|
||||
}
|
||||
|
||||
func NewTextRoute(servlet *VinegarServlet, urlPattern string, pathlike string, useCache bool) *FileRoute {
|
||||
defaultPrune := strings.Replace(urlPattern, ".*", "", -1)
|
||||
fr := FileRoute{srv: servlet, fileRoot: pathlike, UseCache: useCache}
|
||||
textRouteHandler := createCompressibleFileServletFunction(&fr, defaultPrune, pathlike)
|
||||
route := FileRoute{srv: servlet, fileRoot: pathlike, UseCache: useCache}
|
||||
textRouteHandler := createCompressibleFileServletFunction(&route, defaultPrune, pathlike)
|
||||
rootRoute := NewServletRoute(urlPattern, textRouteHandler) //i *still* kinda don't like this pattern
|
||||
fr.VinegarRoute = rootRoute
|
||||
route.VinegarRoute = rootRoute
|
||||
|
||||
return &fr
|
||||
servlet.AddRoute(route.VinegarRoute)
|
||||
|
||||
return &route
|
||||
}
|
||||
|
||||
func NewSingleFileRoute(servlet *VinegarServlet, urlPattern string, pathlike string, useCache bool) *FileRoute {
|
||||
@ -49,6 +53,8 @@ func NewSingleFileRoute(servlet *VinegarServlet, urlPattern string, pathlike str
|
||||
|
||||
route.VinegarRoute = parentRoute
|
||||
|
||||
servlet.AddRoute(route.VinegarRoute)
|
||||
|
||||
return &route
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user