func MiddlewaresFactory(router *httpway.Router) (routes map[string]*httpway.Router) { routes = make(map[string]*httpway.Router) routes["public"] = router routes["private"] = router.Middleware(func(w http.ResponseWriter, r *http.Request) { ctx := httpway.GetContext(r) if !ctx.Session().IsAuth() { w.WriteHeader(http.StatusUnauthorized) fmt.Fprint(w, "Not authenticated") return } ctx.Next(w, r) }) return }