forked from goffee/core
add public path
This commit is contained in:
parent
1bfc72d6a3
commit
711a68699a
1 changed files with 17 additions and 0 deletions
17
core.go
17
core.go
|
@ -81,6 +81,20 @@ func (app *App) Run(router *httprouter.Router) {
|
||||||
portNumber = "80"
|
portNumber = "80"
|
||||||
}
|
}
|
||||||
router = app.RegisterRoutes(ResolveRouter().GetRoutes(), router)
|
router = app.RegisterRoutes(ResolveRouter().GetRoutes(), router)
|
||||||
|
|
||||||
|
// check if template engine is enable
|
||||||
|
TemplateEnableStr := os.Getenv("TEMPLATE_ENABLE")
|
||||||
|
if TemplateEnableStr == "" {
|
||||||
|
TemplateEnableStr = "false"
|
||||||
|
}
|
||||||
|
TemplateEnable, _ := strconv.ParseBool(TemplateEnableStr)
|
||||||
|
// if enabled, add public path
|
||||||
|
if TemplateEnable {
|
||||||
|
|
||||||
|
publicPath := os.Getenv("TEMPLATE_PUBLIC")
|
||||||
|
router.ServeFiles("/public/*filepath", http.Dir(publicPath))
|
||||||
|
}
|
||||||
|
|
||||||
useHttpsStr := os.Getenv("App_USE_HTTPS")
|
useHttpsStr := os.Getenv("App_USE_HTTPS")
|
||||||
if useHttpsStr == "" {
|
if useHttpsStr == "" {
|
||||||
useHttpsStr = "false"
|
useHttpsStr = "false"
|
||||||
|
@ -93,6 +107,8 @@ func (app *App) Run(router *httprouter.Router) {
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("Listening on port %s\nWaiting for requests...\n", portNumber)
|
fmt.Printf("Listening on port %s\nWaiting for requests...\n", portNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if use letsencrypt
|
||||||
UseLetsEncryptStr := os.Getenv("App_USE_LETSENCRYPT")
|
UseLetsEncryptStr := os.Getenv("App_USE_LETSENCRYPT")
|
||||||
if UseLetsEncryptStr == "" {
|
if UseLetsEncryptStr == "" {
|
||||||
UseLetsEncryptStr = "false"
|
UseLetsEncryptStr = "false"
|
||||||
|
@ -135,6 +151,7 @@ func (app *App) RegisterRoutes(routes []Route, router *httprouter.Router) *httpr
|
||||||
router.PanicHandler = panicHandler
|
router.PanicHandler = panicHandler
|
||||||
router.NotFound = notFoundHandler{}
|
router.NotFound = notFoundHandler{}
|
||||||
router.MethodNotAllowed = methodNotAllowed{}
|
router.MethodNotAllowed = methodNotAllowed{}
|
||||||
|
|
||||||
for _, route := range routes {
|
for _, route := range routes {
|
||||||
switch route.Method {
|
switch route.Method {
|
||||||
case GET:
|
case GET:
|
||||||
|
|
Loading…
Reference in a new issue