1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| package controller
import ( "strings"
"github.com/valyala/fasthttp"
"{{{ .Package }}}/app" "{{{ .Package }}}/app/controller/cutil" "{{{ .Package }}}/app/site" "{{{ .Package }}}/app/util" "{{{ .Package }}}/views/verror" )
func Site(rc *fasthttp.RequestCtx) { path := util.StringSplitAndTrim(string(rc.Request.URI().Path()), "/") action := "site" if len(path) > 0 { action += "." + strings.Join(path, ".") } ActSite(action, rc, func(as *app.State, ps *cutil.PageState) (string, error) { redir, page, bc, err := site.Handle(path, as, ps) if err != nil { return "", err } if _, ok := page.(*verror.NotFound); ok { rc.Response.SetStatusCode(404) } if redir != "" { return redir, nil } return Render(rc, as, page, ps, bc...) }) }
|