Aaron Fischer
d0d2c2e64f
PR is open for a month now, so I've added it directly to the docker image to stop waiting. https://code.rocketnine.space/tslocum/twins/pulls/10
79 lines
2.1 KiB
Diff
79 lines
2.1 KiB
Diff
From bd0555069ede209f482a524a9a18fdc9a3f35183 Mon Sep 17 00:00:00 2001
|
|
From: Aaron Fischer <mail@aaron-fischer.net>
|
|
Date: Thu, 3 Jun 2021 23:47:46 +0200
|
|
Subject: [PATCH 1/2] Strip path from root
|
|
|
|
If there is a path (the URL path) specified under paths in the
|
|
configuration, which points to a root (a physical folder on the
|
|
filesystem), this path should not be attached to the root. This fix will
|
|
do that. It strips the path from the root.
|
|
|
|
Example configuration:
|
|
|
|
hosts:
|
|
localhost:
|
|
paths:
|
|
-
|
|
path: /a
|
|
root: public/aroot
|
|
-
|
|
path: /
|
|
root: public
|
|
|
|
Filesystem:
|
|
+ public
|
|
+ index.gmi
|
|
+ aroot
|
|
+ index.gmi
|
|
---
|
|
serve_https.go | 4 +++-
|
|
1 file changed, 3 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/serve_https.go b/serve_https.go
|
|
index e227064..6ab3a41 100644
|
|
--- a/serve_https.go
|
|
+++ b/serve_https.go
|
|
@@ -80,7 +80,9 @@ func serveHTTPS(w http.ResponseWriter, r *http.Request) (int, int64, string) {
|
|
root += "/"
|
|
}
|
|
|
|
- requestSplit := strings.Split(r.URL.Path, "/")
|
|
+ // We remove the the path (specified in the config file) from the actual URL, so
|
|
+ // it will not prefixed two times to the root.
|
|
+ requestSplit := strings.Split(r.URL.Path[len(serve.Path)-1:], "/")
|
|
|
|
if !serve.SymLinks {
|
|
for i := 1; i < len(requestSplit); i++ {
|
|
--
|
|
2.32.0
|
|
|
|
|
|
From 2257e0bcceb8dd2d3f471d679153cd08de4a7ef0 Mon Sep 17 00:00:00 2001
|
|
From: Aaron Fischer <mail@aaron-fischer.net>
|
|
Date: Mon, 7 Jun 2021 23:20:24 +0200
|
|
Subject: [PATCH 2/2] Add some clarification for the paths arrangement
|
|
|
|
---
|
|
CONFIGURATION.md | 5 +++++
|
|
1 file changed, 5 insertions(+)
|
|
|
|
diff --git a/CONFIGURATION.md b/CONFIGURATION.md
|
|
index 46c1987..471ca14 100644
|
|
--- a/CONFIGURATION.md
|
|
+++ b/CONFIGURATION.md
|
|
@@ -90,6 +90,11 @@ See [PROPOSALS.md](https://code.rocketnine.space/tslocum/twins/src/branch/master
|
|
|
|
### Path
|
|
|
|
+Specify any number of paths, which will be checked against the request. The
|
|
+first match will be used to build the response. So keep in mind that the
|
|
+first path should be the most specific one and the last should be the least
|
|
+specific one, like `/`.
|
|
+
|
|
#### Resources
|
|
|
|
One resource must be defined for each path.
|
|
--
|
|
2.32.0
|
|
|