chore: remove unnecessary code (#3161)

This commit is contained in:
Kevin Wan
2023-04-23 22:58:22 +08:00
committed by GitHub
parent ce4eb6ed61
commit 3da740b7fc
4 changed files with 14 additions and 19 deletions

View File

@@ -23,7 +23,7 @@ func CryptionHandler(key []byte) func(http.Handler) http.Handler {
}
// LimitCryptionHandler returns a middleware to handle cryption.
func LimitCryptionHandler(maxBytesSize int64, key []byte) func(http.Handler) http.Handler {
func LimitCryptionHandler(limitBytes int64, key []byte) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
cw := newCryptionResponseWriter(w)
@@ -34,7 +34,7 @@ func LimitCryptionHandler(maxBytesSize int64, key []byte) func(http.Handler) htt
return
}
if err := decryptBody(maxBytesSize, key, r); err != nil {
if err := decryptBody(limitBytes, key, r); err != nil {
w.WriteHeader(http.StatusBadRequest)
return
}
@@ -44,8 +44,8 @@ func LimitCryptionHandler(maxBytesSize int64, key []byte) func(http.Handler) htt
}
}
func decryptBody(maxBytesSize int64, key []byte, r *http.Request) error {
if maxBytesSize > 0 && r.ContentLength > maxBytesSize {
func decryptBody(limitBytes int64, key []byte, r *http.Request) error {
if limitBytes > 0 && r.ContentLength > limitBytes {
return errContentLengthExceeded
}