Hello World in HTML

This commit is contained in:
bel
2020-03-12 15:23:41 -06:00
parent 65655080dd
commit 6d39ef9aa2
3 changed files with 25 additions and 16 deletions

View File

@@ -2,10 +2,8 @@ package server
import (
"fmt"
"local/gziphttp"
"local/router"
"net/http"
"path/filepath"
)
func (s *Server) Routes() error {
@@ -16,7 +14,7 @@ func (s *Server) Routes() error {
}{
{
path: fmt.Sprintf("%s%s", wildcard, wildcard),
handler: s.gzip(s.authenticate(http.NotFound)),
handler: s.gzip(s.authenticate(s.static)),
},
}
@@ -28,16 +26,6 @@ func (s *Server) Routes() error {
return nil
}
func (s *Server) gzip(h http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if gziphttp.Can(r) {
gz := gziphttp.New(w)
defer gz.Close()
w = gz
}
if filepath.Ext(r.URL.Path) == ".css" {
w.Header().Set("Content-Type", "text/css; charset=utf-8")
}
h(w, r)
}
func (s *Server) static(w http.ResponseWriter, r *http.Request) {
s.fileServer.ServeHTTP(w, r)
}