aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-08-25 17:43:21 -0700
committerFuwn <[email protected]>2021-08-25 17:43:21 -0700
commitc3e06e178f2ea82243abd7ce26c7a6d3f19f31ad (patch)
tree384331d6610605234f949ca27c0f3f4d37045f46
parentfix(route): correct redirect route (diff)
downloadspace-c3e06e178f2ea82243abd7ce26c7a6d3f19f31ad.tar.xz
space-c3e06e178f2ea82243abd7ce26c7a6d3f19f31ad.zip
feat(route): redirect route does full redirect
-rw-r--r--handler.go4
-rw-r--r--route.go12
2 files changed, 8 insertions, 8 deletions
diff --git a/handler.go b/handler.go
index 99a7a2f..64be725 100644
--- a/handler.go
+++ b/handler.go
@@ -32,9 +32,9 @@ func errors() {
func meta() {
createFileRoute("/favicon.txt", "favicon.txt")
createFileRoute("/favicon.ico", "favicon.ico")
- createFileRoute("/robots.txt", "robots.txt")
+ createFileRoute("/robots.txt", "robots.txt")
}
func redirect() {
- createRedirectRoute("/x/*", "/proxy")
+ createRedirectRoute("/x/*", "/proxy", true)
}
diff --git a/route.go b/route.go
index 8bfe52a..bfdd649 100644
--- a/route.go
+++ b/route.go
@@ -154,12 +154,12 @@ func legacySupport(baseRoute string) {
})
}
-func createRedirectRoute(route string, redirectRoute string) {
- // TODO: Redirect with path
- //
- // Example:
- // /x/something -> /proxy/something instead of /x/something -> /proxy
+func createRedirectRoute(route string, redirectRoute string, mask bool) {
g.Handle(route, func(c gig.Context) error {
- return c.NoContent(gig.StatusRedirectPermanent, redirectRoute)
+ if mask {
+ return c.NoContent(gig.StatusRedirectPermanent, redirectRoute+c.URL().Path[2:]) // - /x
+ } else {
+ return c.NoContent(gig.StatusRedirectPermanent, redirectRoute)
+ }
})
}