2020-10-13 11:40:16 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "net/http"
|
|
|
|
|
2021-03-22 07:20:56 +00:00
|
|
|
const customPageContextKey = "custompage"
|
|
|
|
|
2021-06-06 12:39:42 +00:00
|
|
|
func (a *goBlog) serveCustomPage(w http.ResponseWriter, r *http.Request) {
|
2021-07-12 14:19:28 +00:00
|
|
|
page := r.Context().Value(customPageContextKey).(*configCustomPage)
|
2021-06-06 12:39:42 +00:00
|
|
|
if a.cfg.Cache != nil && a.cfg.Cache.Enable && page.Cache {
|
2021-03-22 07:20:56 +00:00
|
|
|
if page.CacheExpiration != 0 {
|
2021-05-08 19:22:48 +00:00
|
|
|
setInternalCacheExpirationHeader(w, r, page.CacheExpiration)
|
2021-03-22 07:20:56 +00:00
|
|
|
} else {
|
2021-06-06 12:39:42 +00:00
|
|
|
setInternalCacheExpirationHeader(w, r, int(a.cfg.Cache.Expiration))
|
2020-11-20 14:33:20 +00:00
|
|
|
}
|
2020-10-13 11:40:16 +00:00
|
|
|
}
|
2021-06-06 12:39:42 +00:00
|
|
|
a.render(w, r, page.Template, &renderData{
|
2021-03-22 07:20:56 +00:00
|
|
|
BlogString: r.Context().Value(blogContextKey).(string),
|
2021-06-10 20:09:50 +00:00
|
|
|
Canonical: a.getFullAddress(page.Path),
|
2021-03-22 07:20:56 +00:00
|
|
|
Data: page.Data,
|
|
|
|
})
|
2020-10-13 11:40:16 +00:00
|
|
|
}
|