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
|
return
|
||||||
}
|
}
|
||||||
// Send response
|
// Send response
|
||||||
w.WriteHeader(status)
|
|
||||||
w.Header().Set(contentType, contenttype.ASUTF8)
|
w.Header().Set(contentType, contenttype.ASUTF8)
|
||||||
|
w.WriteHeader(status)
|
||||||
_ = a.min.Get().Minify(contenttype.AS, w, bytes.NewReader(binary))
|
_ = a.min.Get().Minify(contenttype.AS, w, bytes.NewReader(binary))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,10 +62,10 @@ type Compressor struct {
|
||||||
func NewCompressor(level int, types ...string) *Compressor {
|
func NewCompressor(level int, types ...string) *Compressor {
|
||||||
// If types are provided, set those as the allowed types. If none are
|
// If types are provided, set those as the allowed types. If none are
|
||||||
// provided, use the default list.
|
// provided, use the default list.
|
||||||
allowedTypes := map[string]any{}
|
allowedTypes := lo.SliceToMap(
|
||||||
for _, t := range lo.If(len(types) > 0, types).Else(defaultCompressibleContentTypes) {
|
lo.If(len(types) > 0, types).Else(defaultCompressibleContentTypes),
|
||||||
allowedTypes[t] = nil
|
func(t string) (string, any) { return t, nil },
|
||||||
}
|
)
|
||||||
|
|
||||||
c := &Compressor{
|
c := &Compressor{
|
||||||
level: level,
|
level: level,
|
||||||
|
|
Loading…
Reference in New Issue