Don't redirect to absolute URL (fixes #166)
This commit is contained in:
parent
0d55cf4be5
commit
ac74ee1468
@ -25,6 +25,8 @@ var (
|
|||||||
configInSync = true
|
configInSync = true
|
||||||
guiErrors = []guiError{}
|
guiErrors = []guiError{}
|
||||||
guiErrorsMut sync.Mutex
|
guiErrorsMut sync.Mutex
|
||||||
|
static = embeddedStatic()
|
||||||
|
staticFunc = static.(func(http.ResponseWriter, *http.Request))
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -53,7 +55,7 @@ func startGUI(cfg GUIConfiguration, m *Model) {
|
|||||||
if len(cfg.User) > 0 && len(cfg.Password) > 0 {
|
if len(cfg.User) > 0 && len(cfg.Password) > 0 {
|
||||||
mr.Use(basic(cfg.User, cfg.Password))
|
mr.Use(basic(cfg.User, cfg.Password))
|
||||||
}
|
}
|
||||||
mr.Use(embeddedStatic())
|
mr.Use(static)
|
||||||
mr.Use(martini.Recovery())
|
mr.Use(martini.Recovery())
|
||||||
mr.Use(restMiddleware)
|
mr.Use(restMiddleware)
|
||||||
mr.Action(router.Handle)
|
mr.Action(router.Handle)
|
||||||
@ -66,7 +68,8 @@ func startGUI(cfg GUIConfiguration, m *Model) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getRoot(w http.ResponseWriter, r *http.Request) {
|
func getRoot(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Redirect(w, r, "/index.html", 302)
|
r.URL.Path = "/index.html"
|
||||||
|
staticFunc(w, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func restMiddleware(w http.ResponseWriter, r *http.Request) {
|
func restMiddleware(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
@ -4,7 +4,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"mime"
|
"mime"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -16,7 +15,7 @@ import (
|
|||||||
func embeddedStatic() interface{} {
|
func embeddedStatic() interface{} {
|
||||||
var modt = time.Now().UTC().Format(http.TimeFormat)
|
var modt = time.Now().UTC().Format(http.TimeFormat)
|
||||||
|
|
||||||
return func(res http.ResponseWriter, req *http.Request, log *log.Logger) {
|
return func(res http.ResponseWriter, req *http.Request) {
|
||||||
file := req.URL.Path
|
file := req.URL.Path
|
||||||
|
|
||||||
if file[0] == '/' {
|
if file[0] == '/' {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user