option to disable the homepage
This commit is contained in:
parent
24febefba4
commit
40aa6c8917
@ -24,6 +24,7 @@ type ServerOptions struct {
|
|||||||
DBPath string
|
DBPath string
|
||||||
BandwidthLimit int64
|
BandwidthLimit int64
|
||||||
TrustXForwardedFor bool
|
TrustXForwardedFor bool
|
||||||
|
EnableHomepage bool
|
||||||
ServerPublicProperties
|
ServerPublicProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,10 +120,10 @@ func (this *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
// Blanket allow (headers already set)
|
// Blanket allow (headers already set)
|
||||||
w.WriteHeader(200)
|
w.WriteHeader(200)
|
||||||
|
|
||||||
} else if r.Method == "GET" && r.URL.Path == `/` {
|
} else if r.Method == "GET" && r.URL.Path == `/` && this.opts.EnableHomepage {
|
||||||
http.Redirect(w, r, `/index.html`, http.StatusFound)
|
http.Redirect(w, r, `/index.html`, http.StatusFound)
|
||||||
|
|
||||||
} else if static, err := Asset(r.URL.Path[1:]); err == nil && r.Method == "GET" {
|
} else if static, err := Asset(r.URL.Path[1:]); err == nil && r.Method == "GET" && (this.opts.EnableHomepage || r.URL.Path != `/index.html`) {
|
||||||
http.ServeContent(w, r, r.URL.Path[1:], this.startTime, bytes.NewReader(static))
|
http.ServeContent(w, r, r.URL.Path[1:], this.startTime, bytes.NewReader(static))
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -19,6 +19,7 @@ func main() {
|
|||||||
maxUploadMb := flag.Int("max", 8, "Maximum size of uploaded files in MiB (set zero for unlimited)")
|
maxUploadMb := flag.Int("max", 8, "Maximum size of uploaded files in MiB (set zero for unlimited)")
|
||||||
maxUploadSpeed := flag.Int("speed", 0, "Maximum upload speed in bytes/sec (set zero for unlimited)")
|
maxUploadSpeed := flag.Int("speed", 0, "Maximum upload speed in bytes/sec (set zero for unlimited)")
|
||||||
trustXForwardedFor := flag.Bool("trustXForwardedFor", false, "Trust X-Forwarded-For reverse proxy headers")
|
trustXForwardedFor := flag.Bool("trustXForwardedFor", false, "Trust X-Forwarded-For reverse proxy headers")
|
||||||
|
enableHomepage := flag.Bool("enableHomepage", true, "Enable homepage (disable for embedded use only)")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
@ -27,6 +28,7 @@ func main() {
|
|||||||
DBPath: *dbPath,
|
DBPath: *dbPath,
|
||||||
BandwidthLimit: int64(*maxUploadSpeed),
|
BandwidthLimit: int64(*maxUploadSpeed),
|
||||||
TrustXForwardedFor: *trustXForwardedFor,
|
TrustXForwardedFor: *trustXForwardedFor,
|
||||||
|
EnableHomepage: *enableHomepage,
|
||||||
ServerPublicProperties: contented.ServerPublicProperties{
|
ServerPublicProperties: contented.ServerPublicProperties{
|
||||||
AppTitle: *appTitle,
|
AppTitle: *appTitle,
|
||||||
MaxUploadBytes: int64(*maxUploadMb) * 1024 * 1024,
|
MaxUploadBytes: int64(*maxUploadMb) * 1024 * 1024,
|
||||||
|
Loading…
Reference in New Issue
Block a user