Serve robots and favicon
This commit is contained in:
parent
19d32f1e5c
commit
d8a2ac94c9
3 changed files with 11 additions and 2 deletions
|
@ -5,9 +5,9 @@ import (
|
|||
"net/http"
|
||||
)
|
||||
|
||||
const templatesFolder = "templates/"
|
||||
const TemplatesFolder = "templates/"
|
||||
|
||||
func ParseAndServeHtml(w http.ResponseWriter, htmlFile string, info interface{}) {
|
||||
parsedHtml, _ := template.ParseFiles(templatesFolder+htmlFile, templatesFolder+"_base.gohtml")
|
||||
parsedHtml, _ := template.ParseFiles(TemplatesFolder+htmlFile, TemplatesFolder+"_base.gohtml")
|
||||
_ = parsedHtml.Execute(w, info)
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package server
|
|||
|
||||
import (
|
||||
"github.com/go-chi/chi/v5"
|
||||
"godash/files"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
@ -15,6 +16,12 @@ func (server *Server) setupRouter() {
|
|||
})
|
||||
r.Get("/weather", getWeather)
|
||||
})
|
||||
server.Router.Get("/robots.txt", func(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, files.TemplatesFolder+"/robots.txt")
|
||||
})
|
||||
server.Router.Get("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, "static/favicon/favicon.ico")
|
||||
})
|
||||
server.serveStatic("static")
|
||||
server.serveStatic("storage/icons")
|
||||
server.Router.NotFound(func(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
2
templates/robots.txt
Normal file
2
templates/robots.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
User-agent: *
|
||||
Disallow: /
|
Loading…
Add table
Reference in a new issue