Paul 4 years ago
parent
commit
edb97d64f8
3 changed files with 11 additions and 4 deletions
  1. 1
    4
      request/go.mod
  2. 5
    0
      request/go.sum
  3. 5
    0
      request/request.go

+ 1
- 4
request/go.mod View File

@@ -1,7 +1,6 @@
1 1
 module git.links123.net/links123.com/pkg/request
2 2
 
3 3
 require (
4
-	github.com/davecgh/go-spew v1.1.1 // indirect
5 4
 	github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7 // indirect
6 5
 	github.com/gin-gonic/gin v1.3.0
7 6
 	github.com/golang/protobuf v1.2.0 // indirect
@@ -9,13 +8,11 @@ require (
9 8
 	github.com/mattn/go-isatty v0.0.4 // indirect
10 9
 	github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
11 10
 	github.com/modern-go/reflect2 v1.0.1 // indirect
12
-	github.com/pmezard/go-difflib v1.0.0 // indirect
13
-	github.com/stretchr/testify v1.2.2 // indirect
11
+	github.com/sirupsen/logrus v1.4.2
14 12
 	github.com/ugorji/go/codec v0.0.0-20180831062425-e253f1f20942 // indirect
15 13
 	github.com/wpajqz/linker v0.0.0-20180920052826-c21901f38257
16 14
 	golang.org/x/net v0.0.0-20181102091132-c10e9556a7bc // indirect
17 15
 	golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f // indirect
18
-	golang.org/x/sys v0.0.0-20180918153733-ee1b12c67af4 // indirect
19 16
 	gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
20 17
 	gopkg.in/go-playground/validator.v8 v8.18.2 // indirect
21 18
 	gopkg.in/yaml.v2 v2.2.1 // indirect

+ 5
- 0
request/go.sum View File

@@ -10,6 +10,7 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
10 10
 github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
11 11
 github.com/json-iterator/go v1.1.5 h1:gL2yXlmiIo4+t+y32d4WGwOjKGYcGOuyrg46vadswDE=
12 12
 github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
13
+github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
13 14
 github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
14 15
 github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
15 16
 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
@@ -18,6 +19,9 @@ github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9
18 19
 github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
19 20
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
20 21
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
22
+github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
23
+github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
24
+github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
21 25
 github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
22 26
 github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
23 27
 github.com/ugorji/go/codec v0.0.0-20180831062425-e253f1f20942 h1:CZORS/4d6i+5FKSAtbRIjlElV2BAFYv/bokcaEVUimQ=
@@ -32,6 +36,7 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6Zh
32 36
 golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
33 37
 golang.org/x/sys v0.0.0-20180918153733-ee1b12c67af4 h1:h8ij2QOL81JqJ/Vi5Ru+hl4a1yct8+XDGrgBhG0XbuE=
34 38
 golang.org/x/sys v0.0.0-20180918153733-ee1b12c67af4/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
39
+golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
35 40
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
36 41
 gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM=
37 42
 gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=

+ 5
- 0
request/request.go View File

@@ -5,6 +5,7 @@ import (
5 5
 	"net/http"
6 6
 
7 7
 	"github.com/gin-gonic/gin"
8
+	"github.com/sirupsen/logrus"
8 9
 )
9 10
 
10 11
 type Checker interface {
@@ -52,6 +53,10 @@ func Fail(ctx *gin.Context, err error) bool {
52 53
 		status = v.Status
53 54
 	}
54 55
 
56
+	if status == http.StatusInternalServerError {
57
+		logrus.Error(err)
58
+	}
59
+
55 60
 	ctx.JSON(status, gin.H{"msg": err.Error()})
56 61
 
57 62
 	return true