2020-10-13 11:40:16 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "net/http"
|
|
|
|
|
2021-03-22 07:20:56 +00:00
|
|
|
const customPageContextKey = "custompage"
|
|
|
|
|
|
|
|
func serveCustomPage(w http.ResponseWriter, r *http.Request) {
|
|
|
|
page := r.Context().Value(customPageContextKey).(*customPage)
|
|
|
|
if appConfig.Cache != nil && appConfig.Cache.Enable && page.Cache {
|
|
|
|
if page.CacheExpiration != 0 {
|
|
|
|
setInternalCacheExpirationHeader(w, page.CacheExpiration)
|
|
|
|
} else {
|
|
|
|
setInternalCacheExpirationHeader(w, int(appConfig.Cache.Expiration))
|
2020-11-20 14:33:20 +00:00
|
|
|
}
|
2020-10-13 11:40:16 +00:00
|
|
|
}
|
2021-03-22 07:20:56 +00:00
|
|
|
render(w, r, page.Template, &renderData{
|
|
|
|
BlogString: r.Context().Value(blogContextKey).(string),
|
|
|
|
Canonical: appConfig.Server.PublicAddress + page.Path,
|
|
|
|
Data: page.Data,
|
|
|
|
})
|
2020-10-13 11:40:16 +00:00
|
|
|
}
|