Skip to content

Commit

Permalink
I forgot some headers
Browse files Browse the repository at this point in the history
  • Loading branch information
williammck committed Jan 16, 2024
1 parent e7ebfd8 commit bd53a61
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/server/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ import (

func stringHandler(content *string, mimeType string) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Cache-Control", "public, max-age=15")
w.Header().Set("Content-Type", mimeType)
w.Write([]byte(*content))
})
}

func jsonMarshalHandler(content interface{}) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Cache-Control", "public, max-age=15")
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(content)
})
Expand Down

0 comments on commit bd53a61

Please sign in to comment.