mirror of
https://github.com/mattermost/focalboard.git
synced 2024-11-24 08:22:29 +02:00
Allowing subpath in development environment (#3000)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
parent
8d2cc3ed06
commit
8cefcd8e8c
@ -27,17 +27,23 @@ type RoutedService interface {
|
||||
type Server struct {
|
||||
http.Server
|
||||
|
||||
baseURL string
|
||||
rootPath string
|
||||
port int
|
||||
ssl bool
|
||||
logger *mlog.Logger
|
||||
baseURL string
|
||||
rootPath string
|
||||
basePrefix string
|
||||
port int
|
||||
ssl bool
|
||||
logger *mlog.Logger
|
||||
}
|
||||
|
||||
// NewServer creates a new instance of the webserver.
|
||||
func NewServer(rootPath string, serverRoot string, port int, ssl, localOnly bool, logger *mlog.Logger) *Server {
|
||||
r := mux.NewRouter()
|
||||
|
||||
basePrefix := os.Getenv("FOCALBOARD_HTTP_SERVER_BASEPATH")
|
||||
if basePrefix != "" {
|
||||
r = r.PathPrefix(basePrefix).Subrouter()
|
||||
}
|
||||
|
||||
var addr string
|
||||
if localOnly {
|
||||
addr = fmt.Sprintf(`localhost:%d`, port)
|
||||
@ -57,11 +63,12 @@ func NewServer(rootPath string, serverRoot string, port int, ssl, localOnly bool
|
||||
Addr: addr,
|
||||
Handler: r,
|
||||
},
|
||||
baseURL: baseURL,
|
||||
rootPath: rootPath,
|
||||
port: port,
|
||||
ssl: ssl,
|
||||
logger: logger,
|
||||
baseURL: baseURL,
|
||||
rootPath: rootPath,
|
||||
port: port,
|
||||
ssl: ssl,
|
||||
logger: logger,
|
||||
basePrefix: basePrefix,
|
||||
}
|
||||
|
||||
return ws
|
||||
@ -77,7 +84,7 @@ func (ws *Server) AddRoutes(rs RoutedService) {
|
||||
}
|
||||
|
||||
func (ws *Server) registerRoutes() {
|
||||
ws.Router().PathPrefix("/static").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir(filepath.Join(ws.rootPath, "static")))))
|
||||
ws.Router().PathPrefix("/static").Handler(http.StripPrefix(ws.basePrefix+"/static/", http.FileServer(http.Dir(filepath.Join(ws.rootPath, "static")))))
|
||||
ws.Router().PathPrefix("/").HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
indexTemplate, err := template.New("index").ParseFiles(path.Join(ws.rootPath, "index.html"))
|
||||
|
Loading…
Reference in New Issue
Block a user