Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Handle slash trimmed path in example server #1118

Merged
merged 1 commit into from
Apr 23, 2024
Merged

Conversation

blmhemu
Copy link
Contributor

@blmhemu blmhemu commented Apr 22, 2024

The tusd handler works on slash trimmed paths i.e /files. Making the example server do the same.

Usecase:
Just wasted a couple of hours debugging this behaviour using the example server.

Copy link
Member

@Acconut Acconut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much! The comment above the call to http.Handle also just adds to the confusion, making this a great improvement.

Just as a reference for others: This mirrors the logic from the tusd CLI:

tusd/cmd/tusd/cli/serve.go

Lines 94 to 100 in 15f05c0

// ... and register a route with and without the trailing slash, so we can
// handle uploads for /files/ and /files, for example.
basepathWithoutSlash := strings.TrimSuffix(basepath, "/")
basepathWithSlash := basepathWithoutSlash + "/"
mux.Handle(basepathWithSlash, http.StripPrefix(basepathWithSlash, handler))
mux.Handle(basepathWithoutSlash, http.StripPrefix(basepathWithoutSlash, handler))

@Acconut Acconut changed the title Handle slash trimmed path in example server docs: Handle slash trimmed path in example server Apr 23, 2024
@Acconut Acconut merged commit 26c8870 into tus:main Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants