Switch main report page to better example
This is still pulling from our generic district mock, but it's still better than what we had. This also includes adding static content hosting for the bootstrap content on the public domain.
This commit is contained in:
parent
0f82e4c0ef
commit
9774452821
19 changed files with 276 additions and 313 deletions
|
|
@ -6,6 +6,33 @@ import (
|
|||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
// Custom ResponseWriter to track Content-Type
|
||||
type customResponseWriter struct {
|
||||
http.ResponseWriter
|
||||
contentType string
|
||||
wroteHeader bool
|
||||
}
|
||||
|
||||
func (crw *customResponseWriter) WriteHeader(code int) {
|
||||
crw.wroteHeader = true
|
||||
crw.ResponseWriter.WriteHeader(code)
|
||||
}
|
||||
|
||||
func (crw *customResponseWriter) Header() http.Header {
|
||||
return crw.ResponseWriter.Header()
|
||||
}
|
||||
|
||||
func (crw *customResponseWriter) Write(b []byte) (int, error) {
|
||||
if !crw.wroteHeader {
|
||||
if crw.contentType == "" {
|
||||
crw.contentType = http.DetectContentType(b)
|
||||
crw.ResponseWriter.Header().Set("Content-Type", crw.contentType)
|
||||
}
|
||||
crw.WriteHeader(http.StatusOK)
|
||||
}
|
||||
return crw.ResponseWriter.Write(b)
|
||||
}
|
||||
|
||||
// Respond with an error that is visible to the user
|
||||
func respondError(w http.ResponseWriter, m string, e error, s int) {
|
||||
log.Warn().Int("status", s).Err(e).Str("user message", m).Msg("Responding with an error")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue