Add a basic main page with login
None of the links work and the marketing copy sucks, but it's just showing the bones while I figure the technical bits out.
This commit is contained in:
parent
25039a8f54
commit
56eaa4ed1c
10 changed files with 266 additions and 3 deletions
31
response.go
Normal file
31
response.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package main
|
||||
import (
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// 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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue