diff --git a/examples/full-app-gourmet/static/embed.go b/examples/full-app-gourmet/static/embed.go index aae2b2a1..68460bbe 100644 --- a/examples/full-app-gourmet/static/embed.go +++ b/examples/full-app-gourmet/static/embed.go @@ -6,10 +6,10 @@ import ( ) //go:embed * -var staticFiles embed.FS +var StaticFiles embed.FS // Handler returns a http.Handler that will serve files from // the given file system. func Handler() http.Handler { - return http.FileServer(http.FS(staticFiles)) + return http.FileServer(http.FS(StaticFiles)) } diff --git a/examples/full-app-gourmet/static/embed_test.go b/examples/full-app-gourmet/static/embed_test.go index 432a16ca..fb4c4289 100644 --- a/examples/full-app-gourmet/static/embed_test.go +++ b/examples/full-app-gourmet/static/embed_test.go @@ -42,6 +42,5 @@ func TestHandler(t *testing.T) { } t.Log(w.Body.String()) - t.Fail() }) } diff --git a/examples/full-app-gourmet/static/robots.txt b/examples/full-app-gourmet/static/robots.txt new file mode 100644 index 00000000..0afcae4a --- /dev/null +++ b/examples/full-app-gourmet/static/robots.txt @@ -0,0 +1,3 @@ +User-agent: * +Allow: / +Disallow: /admin/ diff --git a/examples/full-app-gourmet/views/recipe.go b/examples/full-app-gourmet/views/recipe.go index 9401c8db..a7c7f5f0 100644 --- a/examples/full-app-gourmet/views/recipe.go +++ b/examples/full-app-gourmet/views/recipe.go @@ -10,6 +10,7 @@ import ( "path" "time" + "github.com/go-fuego/fuego/examples/full-app-gourmet/static" "github.com/go-fuego/fuego/examples/full-app-gourmet/store" "github.com/go-fuego/fuego/examples/full-app-gourmet/templa" @@ -43,6 +44,10 @@ func (rs Ressource) showRecipesStd(w http.ResponseWriter, r *http.Request) { } } +func (rs Ressource) robots(w http.ResponseWriter, r *http.Request) { + http.ServeFileFS(w, r, static.StaticFiles, "robots.txt") +} + func (rs Ressource) showIndex(c fuego.ContextNoBody) (fuego.Templ, error) { timeDBRequest := time.Now() diff --git a/examples/full-app-gourmet/views/views.go b/examples/full-app-gourmet/views/views.go index 8b077a6d..f6f177bc 100644 --- a/examples/full-app-gourmet/views/views.go +++ b/examples/full-app-gourmet/views/views.go @@ -12,6 +12,7 @@ func (rs Ressource) Routes(s *fuego.Server) { // Public Pages fuego.GetStd(s, "/recipes-std", rs.showRecipesStd) fuego.Get(s, "/", rs.showIndex, cache.New()) + fuego.GetStd(s, "/robots.txt", rs.robots, cache.New()) fuego.Get(s, "/recipes", rs.showRecipes) fuego.Get(s, "/planner", rs.planner) fuego.Get(s, "/recipes/{id}", rs.showSingleRecipes2)