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.ServeStatic("/assets/*filepath", web.Assets())
|
||||||
r.Handler(http.MethodGet, "/favicon.ico", dwhttp.FaviconIco)
|
r.Handler(http.MethodGet, "/favicon.ico", dwhttp.ServeAsset("img/favicon.ico"))
|
||||||
r.Handler(http.MethodGet, "/robots.txt", dwhttp.RobotsTxt)
|
r.Handler(http.MethodGet, "/robots.txt", dwhttp.ServeAsset("robots.txt"))
|
||||||
r.Handler(http.MethodGet, "/rss.xml", hand.RSS)
|
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, "/", hand.Index)
|
||||||
r.Handler(http.MethodGet, "/privacy", hand.Privacy)
|
r.Handler(http.MethodGet, "/privacy", hand.Privacy)
|
||||||
|
@ -168,29 +168,20 @@ func (h *Handlers) RSS(w http.ResponseWriter, r *http.Request) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var scheme string
|
|
||||||
if r.Header.Get("Scheme") != "" {
|
scheme := r.Header.Get("Scheme")
|
||||||
scheme = r.Header.Get("Scheme")
|
if scheme == "" {
|
||||||
} else {
|
|
||||||
scheme = "http"
|
scheme = "http"
|
||||||
}
|
}
|
||||||
|
|
||||||
web.RSS(scheme+"://"+r.Host, h.owner, posts, r, w)
|
web.RSS(scheme+"://"+r.Host, h.owner, posts, r, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func FaviconIco(w http.ResponseWriter, r *http.Request) {
|
func ServeAsset(path string) func(http.ResponseWriter, *http.Request) {
|
||||||
data, _ := web.AssetsGetFile("img/favicon.ico")
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Write(data)
|
data, _ := web.AssetsGetFile(path)
|
||||||
}
|
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")
|
|
||||||
w.Write(data)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Error(w http.ResponseWriter, code int, reason, message, referer string) {
|
func Error(w http.ResponseWriter, code int, reason, message, referer string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user