diff options
| author | Fuwn <[email protected]> | 2021-08-25 17:43:21 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-08-25 17:43:21 -0700 |
| commit | c3e06e178f2ea82243abd7ce26c7a6d3f19f31ad (patch) | |
| tree | 384331d6610605234f949ca27c0f3f4d37045f46 | |
| parent | fix(route): correct redirect route (diff) | |
| download | space-c3e06e178f2ea82243abd7ce26c7a6d3f19f31ad.tar.xz space-c3e06e178f2ea82243abd7ce26c7a6d3f19f31ad.zip | |
feat(route): redirect route does full redirect
| -rw-r--r-- | handler.go | 4 | ||||
| -rw-r--r-- | route.go | 12 |
2 files changed, 8 insertions, 8 deletions
@@ -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) } @@ -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) + } }) } |