A set of funcs to serve certain files was replaced by ServeAsset() func where you have to pass a path to an asset within an asset dir.
This commit is contained in:
parent
dca3804090
commit
f9dabbc6f9
@ -60,10 +60,10 @@ func main() {
|
||||
}
|
||||
|
||||
r.ServeStatic("/assets/*filepath", web.Assets())
|
||||
r.Handler(http.MethodGet, "/favicon.ico", dwhttp.FaviconIco)
|
||||
r.Handler(http.MethodGet, "/robots.txt", dwhttp.RobotsTxt)
|
||||
r.Handler(http.MethodGet, "/favicon.ico", dwhttp.ServeAsset("img/favicon.ico"))
|
||||
r.Handler(http.MethodGet, "/robots.txt", dwhttp.ServeAsset("robots.txt"))
|
||||
r.Handler(http.MethodGet, "/rss.xml", hand.RSS)
|
||||
r.Handler(http.MethodGet, "/sitemap.xml", dwhttp.SitemapXml)
|
||||
r.Handler(http.MethodGet, "/sitemap.xml", dwhttp.ServeAsset("sitemap.xml"))
|
||||
|
||||
r.Handler(http.MethodGet, "/", hand.Index)
|
||||
r.Handler(http.MethodGet, "/privacy", hand.Privacy)
|
||||
|
@ -168,29 +168,20 @@ func (h *Handlers) RSS(w http.ResponseWriter, r *http.Request) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
var scheme string
|
||||
if r.Header.Get("Scheme") != "" {
|
||||
scheme = r.Header.Get("Scheme")
|
||||
} else {
|
||||
|
||||
scheme := r.Header.Get("Scheme")
|
||||
if scheme == "" {
|
||||
scheme = "http"
|
||||
}
|
||||
|
||||
web.RSS(scheme+"://"+r.Host, h.owner, posts, r, w)
|
||||
}
|
||||
|
||||
func FaviconIco(w http.ResponseWriter, r *http.Request) {
|
||||
data, _ := web.AssetsGetFile("img/favicon.ico")
|
||||
w.Write(data)
|
||||
}
|
||||
|
||||
func RobotsTxt(w http.ResponseWriter, r *http.Request) {
|
||||
data, _ := web.AssetsGetFile("robots.txt")
|
||||
w.Write(data)
|
||||
}
|
||||
|
||||
func SitemapXml(w http.ResponseWriter, r *http.Request) {
|
||||
data, _ := web.AssetsGetFile("sitemap.xml")
|
||||
func ServeAsset(path string) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
data, _ := web.AssetsGetFile(path)
|
||||
w.Write(data)
|
||||
}
|
||||
}
|
||||
|
||||
func Error(w http.ResponseWriter, code int, reason, message, referer string) {
|
||||
|
Loading…
Reference in New Issue
Block a user