Redirect root url to index

This commit is contained in:
2021-12-03 03:13:15 +01:00
parent 48df063c86
commit c1b2b721e6
2 changed files with 12 additions and 0 deletions
+11
View File
@@ -1,10 +1,21 @@
package renderer package renderer
import ( import (
"net/http"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/content" "code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/content"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/templates"
routing "github.com/jackwhelpton/fasthttp-routing/v2" routing "github.com/jackwhelpton/fasthttp-routing/v2"
) )
// rootRedirect redirects the root url to the index using http redirect
func (r *Renderer) rootRedirect(c *routing.Context) (err error) {
c.Redirect(templates.URLIndex, http.StatusFound)
return
}
// index handler renders index data // index handler renders index data
func (r *Renderer) index(c *routing.Context) (err error) { func (r *Renderer) index(c *routing.Context) (err error) {
+1
View File
@@ -34,6 +34,7 @@ func (r *Renderer) init() {
router.NotFound(r.errorNotFound) router.NotFound(r.errorNotFound)
root := router.Group(r.Base) root := router.Group(r.Base)
root.Get(templates.URLRoot, r.rootRedirect)
root.Get(templates.URLIndex, r.index) root.Get(templates.URLIndex, r.index)
root.Get(templates.URLBlog, r.blog) root.Get(templates.URLBlog, r.blog)