cli: Allow uploads without trailing slash
This commit is contained in:
parent
bfac68d84c
commit
141a49a38d
|
@ -3,6 +3,7 @@ package cli
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/tus/tusd/pkg/handler"
|
"github.com/tus/tusd/pkg/handler"
|
||||||
|
@ -63,6 +64,13 @@ func Serve() {
|
||||||
|
|
||||||
http.Handle(basepath, http.StripPrefix(basepath, handler))
|
http.Handle(basepath, http.StripPrefix(basepath, handler))
|
||||||
|
|
||||||
|
// Also register a route without the trailing slash, so we can handle uploads
|
||||||
|
// for /files/ and /files, for example.
|
||||||
|
if strings.HasSuffix(basepath, "/") {
|
||||||
|
basepathWithoutSlash := strings.TrimSuffix(basepath, "/")
|
||||||
|
http.Handle(basepathWithoutSlash, http.StripPrefix(basepathWithoutSlash, handler))
|
||||||
|
}
|
||||||
|
|
||||||
var listener net.Listener
|
var listener net.Listener
|
||||||
timeoutDuration := time.Duration(Flags.Timeout) * time.Millisecond
|
timeoutDuration := time.Duration(Flags.Timeout) * time.Millisecond
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue