ch10.2
This commit is contained in:
@@ -74,7 +74,7 @@ func main() {
|
||||
}
|
||||
|
||||
infoLog.Printf("Starting server on %s", cfg.addr)
|
||||
err = srv.ListenAndServe()
|
||||
err = srv.ListenAndServeTLS("./tls/cert.pem", "./tls/key.pem")
|
||||
errorLog.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@ import (
|
||||
|
||||
func secureHeaders(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Security-Policy",
|
||||
"default-src 'self'; style-src 'self' fonts.googleapis.com; font-src fonts.gstatic.com")
|
||||
w.Header().Set("Referrer-Policy", "origin-when-cross-origin")
|
||||
w.Header().Set("X-Content-Type-Options", "nosniff")
|
||||
w.Header().Set("X-Frame-Options", "deny")
|
||||
w.Header().Set("X-XSS-Protection", "0")
|
||||
//w.Header().Set("Content-Security-Policy",
|
||||
// "default-src 'self'; style-src 'self' fonts.googleapis.com; font-src fonts.gstatic.com")
|
||||
//w.Header().Set("Referrer-Policy", "origin-when-cross-origin")
|
||||
//w.Header().Set("X-Content-Type-Options", "nosniff")
|
||||
//w.Header().Set("X-Frame-Options", "deny")
|
||||
//w.Header().Set("X-XSS-Protection", "0")
|
||||
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
|
||||
@@ -15,7 +15,7 @@ func (app *application) routes() http.Handler {
|
||||
})
|
||||
|
||||
fileServer := http.FileServer(http.Dir("./ui/static/"))
|
||||
router.Handler(http.MethodGet, "/static/", http.StripPrefix("/static", fileServer))
|
||||
router.Handler(http.MethodGet, "/static/*filepath", http.StripPrefix("/static", fileServer))
|
||||
|
||||
dynamic := alice.New(app.sessionManager.LoadAndSave)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user