File tree Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import (
4
+ "log"
4
5
"net/http"
5
6
6
7
limits "github.com/gin-contrib/size"
@@ -16,8 +17,10 @@ func handler(ctx *gin.Context) {
16
17
}
17
18
18
19
func main () {
19
- rtr := gin .Default ()
20
- rtr .Use (limits .RequestSizeLimiter (10 ))
21
- rtr .POST ("/" , handler )
22
- rtr .Run (":8080" )
20
+ r := gin .Default ()
21
+ r .Use (limits .RequestSizeLimiter (10 ))
22
+ r .POST ("/" , handler )
23
+ if err := r .Run (":8080" ); err != nil {
24
+ log .Fatal (err )
25
+ }
23
26
}
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ func (mbr *maxBytesReader) tooLarge() (n int, err error) {
22
22
if ! mbr .wasAborted {
23
23
mbr .wasAborted = true
24
24
ctx := mbr .ctx
25
- ctx .Error (err )
25
+ _ = ctx .Error (err )
26
26
ctx .Header ("connection" , "close" )
27
27
ctx .String (http .StatusRequestEntityTooLarge , "request too large" )
28
28
ctx .AbortWithStatus (http .StatusRequestEntityTooLarge )
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ func TestRequestSizeLimiterOK(t *testing.T) {
14
14
router := gin .New ()
15
15
router .Use (RequestSizeLimiter (10 ))
16
16
router .POST ("/test_ok" , func (c * gin.Context ) {
17
- ioutil .ReadAll (c .Request .Body )
17
+ _ , _ = ioutil .ReadAll (c .Request .Body )
18
18
if len (c .Errors ) > 0 {
19
19
return
20
20
}
@@ -32,7 +32,7 @@ func TestRequestSizeLimiterOver(t *testing.T) {
32
32
router := gin .New ()
33
33
router .Use (RequestSizeLimiter (10 ))
34
34
router .POST ("/test_large" , func (c * gin.Context ) {
35
- ioutil .ReadAll (c .Request .Body )
35
+ _ , _ = ioutil .ReadAll (c .Request .Body )
36
36
if len (c .Errors ) > 0 {
37
37
return
38
38
}
You can’t perform that action at this time.
0 commit comments