Skip to content
This repository was archived by the owner on Feb 28, 2021. It is now read-only.

Commit ea27d1c

Browse files
author
SianLoong
committed
remove Logger & update packages
1 parent 62253f0 commit ea27d1c

File tree

6 files changed

+11
-14
lines changed

6 files changed

+11
-14
lines changed

bind.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func loadValue(v reflect.Value, b []string) error {
4848
return err
4949
}
5050
if v.OverflowInt(x) {
51-
return fmt.Errorf("overflow integer value, %v", x)
51+
return xerrors.Errorf("overflow integer value, %v", x)
5252
}
5353
v.SetInt(x)
5454
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
@@ -66,7 +66,7 @@ func loadValue(v reflect.Value, b []string) error {
6666
return err
6767
}
6868
if v.OverflowFloat(x) {
69-
return fmt.Errorf("overflow float value , %v", x)
69+
return xerrors.Errorf("overflow float value , %v", x)
7070
}
7171
v.SetFloat(x)
7272
case reflect.Interface:

context.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"strings"
1212
"time"
1313

14-
"github.com/pkg/errors"
14+
"golang.org/x/xerrors"
1515

1616
"github.com/ajg/form"
1717
json "github.com/pquerna/ffjson/ffjson"
@@ -51,7 +51,7 @@ func (c *Context) Bind(dst interface{}) error {
5151
v := reflect.ValueOf(dst)
5252
t := v.Type()
5353
if t.Kind() != reflect.Ptr || t.Elem().Kind() != reflect.Struct {
54-
return errors.Errorf("layout is not addressable")
54+
return xerrors.Errorf("layout is not addressable")
5555
}
5656

5757
query := b2s(bytes.TrimSpace(c.QueryArgs().QueryString()))

error.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (e *HTTPError) Error() string {
6868
}
6969

7070
// DefaultErrorHandler :
71-
func (r *Raptor) DefaultErrorHandler(ctx *Context, err error) {
71+
func DefaultErrorHandler(ctx *Context, err error) {
7272
statusCode := ctx.RequestCtx.Response.StatusCode()
7373
if statusCode <= 0 {
7474
statusCode = fasthttp.StatusInternalServerError

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/pkg/errors v0.0.0-20181023235946-059132a15dd0
1616
github.com/pquerna/ffjson v0.0.0-20181028064349-e517b90714f7
1717
github.com/valyala/bytebufferpool v1.0.0
18-
github.com/valyala/fasthttp v1.2.0
18+
github.com/valyala/fasthttp v1.3.0
1919
golang.org/x/sys v0.0.0-20181206074257-70b957f3b65e
2020
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522
2121
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ github.com/valyala/fasthttp v1.2.0 h1:dzZJf2IuMiclVjdw0kkT+f9u4YdrapbNyGAN47E/qn
3030
github.com/valyala/fasthttp v1.2.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s=
3131
github.com/valyala/fasthttp v1.2.1-0.20190302200148-517df8833274 h1:xznJhYDU1cSshjaVzmKgeOOPTVxxZjw1afTN0mIHsug=
3232
github.com/valyala/fasthttp v1.2.1-0.20190302200148-517df8833274/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s=
33+
github.com/valyala/fasthttp v1.3.0 h1:++0WUtakkqBuHHY5JRFFl6O44I03XLBqxNnrBX0yH7Y=
34+
github.com/valyala/fasthttp v1.3.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s=
3335
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
3436
golang.org/x/net v0.0.0-20180911220305-26e67e76b6c3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
3537
golang.org/x/sys v0.0.0-20181206074257-70b957f3b65e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=

raptor.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import (
99

1010
"github.com/buaazp/fasthttprouter"
1111
"github.com/fatih/color"
12-
"github.com/pkg/errors"
1312
"github.com/valyala/fasthttp"
1413
"github.com/valyala/fasthttp/fasthttputil"
14+
"golang.org/x/xerrors"
1515
)
1616

1717
func init() {
@@ -51,7 +51,6 @@ type Raptor struct {
5151
router *fasthttprouter.Router
5252
middlewares []MiddlewareFunc
5353
ErrorHandler func(c *Context, err error)
54-
Logger Logger
5554
IsDebug bool
5655
}
5756

@@ -70,7 +69,7 @@ func New() *Raptor {
7069
router: fasthttprouter.New(),
7170
middlewares: make([]MiddlewareFunc, 0),
7271
}
73-
r.ErrorHandler = r.DefaultErrorHandler
72+
r.ErrorHandler = DefaultErrorHandler
7473
r.IsDebug = true
7574
return r
7675
}
@@ -178,10 +177,6 @@ func (r *Raptor) mergeHandler(handler HandlerFunc, middlewares ...MiddlewareFunc
178177
h = middlewares[i](h)
179178
}
180179
if err := h(c); err != nil {
181-
// Wrap error with pkg/errors
182-
if r.Logger != nil {
183-
r.Logger(err)
184-
}
185180
r.ErrorHandler(c, err)
186181
}
187182
})
@@ -231,7 +226,7 @@ func (r *Raptor) handler(h ...HandlerFunc) fasthttp.RequestHandler {
231226
func (r *Raptor) Start(port string, handler ...HandlerFunc) error {
232227
re := regexp.MustCompile(`^(\:)?(\d+)$`)
233228
if !re.MatchString(port) {
234-
return errors.Errorf("raptor: invalid port format, %q", port)
229+
return xerrors.Errorf("raptor: invalid port format, %q", port)
235230
}
236231
port = ":" + re.FindStringSubmatch(port)[2]
237232
log.Println("fasthttp server started on", port)

0 commit comments

Comments
 (0)