mirror of https://github.com/jlelse/GoBlog
Login form with 200 and no cache header
This commit is contained in:
parent
e25199b2a3
commit
6de2ae6ff3
|
@ -42,7 +42,8 @@ func authMiddleware(next http.Handler) http.Handler {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 3. Show login form
|
// 3. Show login form
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.Header().Set("Cache-Control", "no-cache,no-store,must-revalidate")
|
||||||
h, _ := json.Marshal(r.Header.Clone())
|
h, _ := json.Marshal(r.Header.Clone())
|
||||||
b, _ := io.ReadAll(io.LimitReader(r.Body, 2000000)) // Only allow 20 Megabyte
|
b, _ := io.ReadAll(io.LimitReader(r.Body, 2000000)) // Only allow 20 Megabyte
|
||||||
_ = r.Body.Close()
|
_ = r.Body.Close()
|
||||||
|
|
4
cache.go
4
cache.go
|
@ -178,7 +178,9 @@ func getCache(key string, next http.Handler, r *http.Request) (item *cacheItem)
|
||||||
body: body,
|
body: body,
|
||||||
}
|
}
|
||||||
// Save cache
|
// Save cache
|
||||||
cacheLru.Add(key, item)
|
if cch := item.header.Get("Cache-Control"); !strings.Contains(cch, "no-store") && !strings.Contains(cch, "private") && !strings.Contains(cch, "no-cache") {
|
||||||
|
cacheLru.Add(key, item)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue