Allow users to modify/delete websites #36
@ -40,6 +40,7 @@ type applicationConfig struct {
|
|||||||
localAuthEnabled bool
|
localAuthEnabled bool
|
||||||
oauth applicationOauthConfig
|
oauth applicationOauthConfig
|
||||||
rootUrl string
|
rootUrl string
|
||||||
|
environment string
|
||||||
}
|
}
|
||||||
|
|
||||||
type application struct {
|
type application struct {
|
||||||
@ -158,7 +159,15 @@ func setupConfig(addr string) (applicationConfig, error) {
|
|||||||
oauth2Provider = os.Getenv("OAUTH2_PROVIDER")
|
oauth2Provider = os.Getenv("OAUTH2_PROVIDER")
|
||||||
clientID = os.Getenv("OAUTH2_CLIENT_ID")
|
clientID = os.Getenv("OAUTH2_CLIENT_ID")
|
||||||
clientSecret = os.Getenv("OAUTH2_CLIENT_SECRET")
|
clientSecret = os.Getenv("OAUTH2_CLIENT_SECRET")
|
||||||
|
environment = os.Getenv("ENVIRONMENT")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if environment != "" {
|
||||||
|
c.environment = environment
|
||||||
|
} else {
|
||||||
|
c.environment = "DEV"
|
||||||
|
}
|
||||||
|
|
||||||
if rootUrl != "" {
|
if rootUrl != "" {
|
||||||
c.rootUrl = rootUrl
|
c.rootUrl = rootUrl
|
||||||
} else {
|
} else {
|
||||||
@ -214,6 +223,7 @@ func setupConfig(addr string) (applicationConfig, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.oauth = o
|
c.oauth = o
|
||||||
|
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,12 @@ import (
|
|||||||
|
|
||||||
func (app *application) routes() http.Handler {
|
func (app *application) routes() http.Handler {
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
mux.Handle("GET /static/", http.FileServerFS(ui.Files))
|
if app.config.environment == "PROD" {
|
||||||
|
mux.Handle("GET /static/", http.FileServerFS(ui.Files))
|
||||||
|
} else {
|
||||||
|
fileServer := http.FileServer(http.Dir("./ui/static/"))
|
||||||
|
mux.Handle("GET /static/", http.StripPrefix("/static", fileServer))
|
||||||
|
}
|
||||||
|
|
||||||
mux.HandleFunc("GET /ping", ping)
|
mux.HandleFunc("GET /ping", ping)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user