Skip to content

Commit a5d81b8

Browse files
committed
Updated deps, removed json-iterator, fixed labstack#1087, fixed labstack#1086
Signed-off-by: Vishal Rana <vr@labstack.com>
1 parent 9aafcaf commit a5d81b8

File tree

5 files changed

+18
-37
lines changed

5 files changed

+18
-37
lines changed

Gopkg.lock

+1-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

+1-5
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,4 @@
3939

4040
[[constraint]]
4141
branch = "master"
42-
name = "golang.org/x/crypto"
43-
44-
[[constraint]]
45-
name = "github.com/json-iterator/go"
46-
version = "1.1.2"
42+
name = "golang.org/x/crypto"

context.go

+4-9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package echo
22

33
import (
44
"bytes"
5+
"encoding/json"
56
"encoding/xml"
67
"fmt"
78
"io"
@@ -12,8 +13,6 @@ import (
1213
"os"
1314
"path/filepath"
1415
"strings"
15-
16-
"github.com/json-iterator/go"
1716
)
1817

1918
type (
@@ -207,10 +206,6 @@ const (
207206
indexPage = "index.html"
208207
)
209208

210-
var (
211-
jsoni = jsoniter.ConfigCompatibleWithStandardLibrary
212-
)
213-
214209
func (c *context) writeContentType(value string) {
215210
header := c.Response().Header()
216211
if header.Get(HeaderContentType) == "" {
@@ -414,15 +409,15 @@ func (c *context) JSON(code int, i interface{}) (err error) {
414409
if c.echo.Debug || pretty {
415410
return c.JSONPretty(code, i, " ")
416411
}
417-
b, err := jsoni.Marshal(i)
412+
b, err := json.Marshal(i)
418413
if err != nil {
419414
return
420415
}
421416
return c.JSONBlob(code, b)
422417
}
423418

424419
func (c *context) JSONPretty(code int, i interface{}, indent string) (err error) {
425-
b, err := jsoni.MarshalIndent(i, "", indent)
420+
b, err := json.MarshalIndent(i, "", indent)
426421
if err != nil {
427422
return
428423
}
@@ -434,7 +429,7 @@ func (c *context) JSONBlob(code int, b []byte) (err error) {
434429
}
435430

436431
func (c *context) JSONP(code int, callback string, i interface{}) (err error) {
437-
b, err := jsoni.Marshal(i)
432+
b, err := json.Marshal(i)
438433
if err != nil {
439434
return
440435
}

echo.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -557,15 +557,15 @@ func (e *Echo) ServeHTTP(w http.ResponseWriter, r *http.Request) {
557557
c := e.pool.Get().(*context)
558558
c.Reset(r, w)
559559

560-
method := r.Method
560+
m := r.Method
561561
h := NotFoundHandler
562562

563563
if e.premiddleware == nil {
564564
path := r.URL.RawPath
565565
if path == "" {
566566
path = r.URL.Path
567567
}
568-
e.router.Find(method, path, c)
568+
e.router.Find(m, getPath(r), c)
569569
h = c.Handler()
570570
for i := len(e.middleware) - 1; i >= 0; i-- {
571571
h = e.middleware[i](h)
@@ -576,7 +576,7 @@ func (e *Echo) ServeHTTP(w http.ResponseWriter, r *http.Request) {
576576
if path == "" {
577577
path = r.URL.Path
578578
}
579-
e.router.Find(method, path, c)
579+
e.router.Find(m, getPath(r), c)
580580
h := c.Handler()
581581
for i := len(e.middleware) - 1; i >= 0; i-- {
582582
h = e.middleware[i](h)
@@ -713,6 +713,14 @@ func WrapMiddleware(m func(http.Handler) http.Handler) MiddlewareFunc {
713713
}
714714
}
715715

716+
func getPath(r *http.Request) string {
717+
path := r.URL.RawPath
718+
if path == "" {
719+
path = r.URL.Path
720+
}
721+
return path
722+
}
723+
716724
func handlerName(h HandlerFunc) string {
717725
t := reflect.ValueOf(h).Type()
718726
if t.Kind() == reflect.Func {

middleware/rewrite_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestRewrite(t *testing.T) {
3434
assert.Equal(t, "/user/jack/order/1", req.URL.Path)
3535
}
3636

37-
//Issue #1086
37+
// Issue #1086
3838
func TestEchoRewritePreMiddleware(t *testing.T) {
3939
e := echo.New()
4040
r := e.Router()

0 commit comments

Comments
 (0)