mirror of https://github.com/jlelse/GoBlog
Set content-type before writing status code
This commit is contained in:
parent
75e60326ff
commit
dfc1af4f2e
|
@ -171,8 +171,8 @@ func (a *goBlog) serveAPItem(w http.ResponseWriter, r *http.Request, status int,
|
|||
return
|
||||
}
|
||||
// Send response
|
||||
w.WriteHeader(status)
|
||||
w.Header().Set(contentType, contenttype.ASUTF8)
|
||||
w.WriteHeader(status)
|
||||
_ = a.min.Get().Minify(contenttype.AS, w, bytes.NewReader(binary))
|
||||
}
|
||||
|
||||
|
|
|
@ -62,10 +62,10 @@ type Compressor struct {
|
|||
func NewCompressor(level int, types ...string) *Compressor {
|
||||
// If types are provided, set those as the allowed types. If none are
|
||||
// provided, use the default list.
|
||||
allowedTypes := map[string]any{}
|
||||
for _, t := range lo.If(len(types) > 0, types).Else(defaultCompressibleContentTypes) {
|
||||
allowedTypes[t] = nil
|
||||
}
|
||||
allowedTypes := lo.SliceToMap(
|
||||
lo.If(len(types) > 0, types).Else(defaultCompressibleContentTypes),
|
||||
func(t string) (string, any) { return t, nil },
|
||||
)
|
||||
|
||||
c := &Compressor{
|
||||
level: level,
|
||||
|
|
Loading…
Reference in New Issue