Redirect root url to index

pull/1/head
Nikita Tokarchuk 3 years ago
parent 48df063c86
commit c1b2b721e6
Signed by: mainnika
GPG Key ID: A595FB7E3E56911C
  1. 11
      frontend/renderer/index.go
  2. 1
      frontend/renderer/renderer.go

@ -1,10 +1,21 @@
package renderer
import (
"net/http"
"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"
)
// 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
func (r *Renderer) index(c *routing.Context) (err error) {

@ -34,6 +34,7 @@ func (r *Renderer) init() {
router.NotFound(r.errorNotFound)
root := router.Group(r.Base)
root.Get(templates.URLRoot, r.rootRedirect)
root.Get(templates.URLIndex, r.index)
root.Get(templates.URLBlog, r.blog)

Loading…
Cancel
Save