Hello World in HTML
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user