mirror of
https://github.com/mainnika/nikita-tokarch-uk.git
synced 2026-05-25 01:03:35 +00:00
Always use relative redirect to keep the upstream domain
This commit is contained in:
+11
-4
@@ -1,23 +1,30 @@
|
|||||||
package routes
|
package routes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"bytes"
|
||||||
|
|
||||||
routing "github.com/jackwhelpton/fasthttp-routing/v2"
|
routing "github.com/jackwhelpton/fasthttp-routing/v2"
|
||||||
|
"github.com/valyala/fasthttp"
|
||||||
|
|
||||||
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/content"
|
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/content"
|
||||||
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/params"
|
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/ghost/params"
|
||||||
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/templates"
|
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/templates"
|
||||||
)
|
)
|
||||||
|
|
||||||
// rootRedirect redirects the root url to the index using http redirect
|
// relativeRedirectBytes makes a relative redirect by using http Location header
|
||||||
func (r *Routes) rootRedirect(c *routing.Context) (err error) {
|
func (r *Routes) relativeRedirectBytes(c *routing.Context, location []byte, statusCode int) (err error) {
|
||||||
|
|
||||||
c.Redirect(templates.URLIndex, http.StatusFound)
|
c.Response.Header.SetCanonical([]byte(fasthttp.HeaderLocation), location)
|
||||||
|
c.Response.SetStatusCode(statusCode)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// rootRedirect redirects the root url to the index using http redirect
|
||||||
|
func (r *Routes) rootRedirect(c *routing.Context) (err error) {
|
||||||
|
return r.relativeRedirectBytes(c, []byte(templates.URLIndex), fasthttp.StatusFound)
|
||||||
|
}
|
||||||
|
|
||||||
// index handler renders index data
|
// index handler renders index data
|
||||||
func (r *Routes) index(c *routing.Context) (err error) {
|
func (r *Routes) index(c *routing.Context) (err error) {
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package templates
|
package templates
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
URLPostfix = "aspx"
|
||||||
|
|
||||||
URLRoot = "/"
|
URLRoot = "/"
|
||||||
URLIndex = "/index.aspx"
|
URLIndex = "/index." + URLPostfix
|
||||||
URLBlog = "/blog.aspx"
|
URLBlog = "/blog." + URLPostfix
|
||||||
URLPost = "/post.aspx"
|
URLPost = "/post." + URLPostfix
|
||||||
URLJSApp = "/js-bin/app.js"
|
URLJSApp = "/js-bin/app.js"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user