Skip to content

Commit

Permalink
Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio Andres Virviescas Santana committed Jan 9, 2021
1 parent 32f3c33 commit ad78503
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 28 deletions.
9 changes: 5 additions & 4 deletions atreugo.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import (
"net"
"os"

"github.com/savsgio/gotils"
"github.com/savsgio/gotils/strconv"
"github.com/savsgio/gotils/strings"
"github.com/valyala/fasthttp"
)

Expand All @@ -18,7 +19,7 @@ var (

// New create a new instance of Atreugo Server.
func New(cfg Config) *Atreugo {
if cfg.Network != "" && !gotils.StringSliceInclude(validNetworks, cfg.Network) {
if cfg.Network != "" && !strings.Include(validNetworks, cfg.Network) {
panic("Invalid network: " + cfg.Network)
}

Expand Down Expand Up @@ -107,7 +108,7 @@ func (s *Atreugo) handler() fasthttp.RequestHandler {

if len(s.virtualHosts) > 0 {
handler = func(ctx *fasthttp.RequestCtx) {
hostname := gotils.B2S(ctx.URI().Host())
hostname := strconv.B2S(ctx.URI().Host())

if h := s.virtualHosts[hostname]; h != nil {
h(ctx)
Expand Down Expand Up @@ -208,7 +209,7 @@ func (s *Atreugo) Serve(ln net.Listener) error {
s.cfg.Network = ln.Addr().Network()
s.server.Handler = s.handler()

if gotils.StringSliceInclude(tcpNetworks, s.cfg.Network) {
if strings.Include(tcpNetworks, s.cfg.Network) {
schema := "http"
if s.cfg.TLSEnable {
schema = "https"
Expand Down
17 changes: 10 additions & 7 deletions atreugo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import (
"unicode"

"github.com/atreugo/mock"
"github.com/savsgio/gotils"
"github.com/savsgio/gotils/bytes"
"github.com/savsgio/gotils/strings"
"github.com/valyala/fasthttp"
"github.com/valyala/fasthttp/fasthttputil"
)
Expand Down Expand Up @@ -211,7 +212,7 @@ func Test_newFasthttpServer(t *testing.T) { //nolint:funlen

if !unicode.IsUpper(rune(field.Name[0])) { // Check if the field is public
continue
} else if gotils.StringSliceInclude(notConfigFasthttpFields, field.Name) {
} else if strings.Include(notConfigFasthttpFields, field.Name) {
continue
}

Expand Down Expand Up @@ -280,7 +281,7 @@ func TestAtreugo_handler(t *testing.T) { // nolint:funlen,gocognit

t.Run(tt.name, func(t *testing.T) {
testView := func(ctx *RequestCtx) error {
return ctx.JSONResponse(JSON{"data": gotils.RandBytes(make([]byte, 300))})
return ctx.JSONResponse(JSON{"data": bytes.Rand(make([]byte, 300))})
}
testPath := "/"

Expand All @@ -298,7 +299,7 @@ func TestAtreugo_handler(t *testing.T) { // nolint:funlen,gocognit
t.Errorf("handler is nil")
}

newHostname := string(gotils.RandBytes(make([]byte, 10))) + ".com"
newHostname := string(bytes.Rand(make([]byte, 10))) + ".com"

hosts := tt.args.hosts
hosts = append(hosts, newHostname)
Expand Down Expand Up @@ -563,7 +564,9 @@ func Benchmark_Handler(b *testing.B) {

b.ResetTimer()

for i := 0; i <= b.N; i++ {
handler(ctx)
}
b.RunParallel(func(p *testing.PB) {
for p.Next() {
handler(ctx)
}
})
}
4 changes: 2 additions & 2 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"fmt"
"sync"

"github.com/savsgio/gotils"
"github.com/savsgio/gotils/bytes"
"github.com/valyala/fasthttp"
)

var attachedCtxKey = fmt.Sprintf("__attachedCtx::%s__", gotils.RandBytes(make([]byte, 15)))
var attachedCtxKey = fmt.Sprintf("__attachedCtx::%s__", bytes.Rand(make([]byte, 15)))

var requestCtxPool = &sync.Pool{
New: func() interface{} {
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.12

require (
github.com/atreugo/mock v0.0.0-20200601091009-13c275b330b0
github.com/fasthttp/router v1.3.4
github.com/savsgio/gotils v0.0.0-20200909101946-939aa3fc74fb
github.com/fasthttp/router v1.3.5
github.com/savsgio/gotils v0.0.0-20210105085219-0567298fdcac
github.com/valyala/bytebufferpool v1.0.0
github.com/valyala/fasthttp v1.18.0
github.com/valyala/fasthttp v1.19.0
)
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ github.com/andybalholm/brotli v1.0.0 h1:7UCwP93aiSfvWpapti8g88vVVGp2qqtGyePsSuDa
github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
github.com/atreugo/mock v0.0.0-20200601091009-13c275b330b0 h1:IVqe9WnancrkICl5HqEfGjrnkQ4+VsU5fodcuFVoG/A=
github.com/atreugo/mock v0.0.0-20200601091009-13c275b330b0/go.mod h1:HTHAc8RoZXMVTr6wZQN7Jjm3mYMnbfkqqKdnQgSoe9o=
github.com/fasthttp/router v1.3.4 h1:JvqoHwFpId8DzaKubQLafpZSkJTmbExIJrf+YhB4tio=
github.com/fasthttp/router v1.3.4/go.mod h1:f6W2miwVcZFqrtr6M7I04TAdq1TnlMnMc7Z4fwICuQ4=
github.com/fasthttp/router v1.3.5 h1:XGZZtcYUH+9ZoLxKhwF66F8sGnMT+Jg00j0JdVzwmDA=
github.com/fasthttp/router v1.3.5/go.mod h1:BylQKgvh6YQkR0mvL60+HJyTaGwcn5d8UFNweOb/Nw8=
github.com/klauspost/compress v1.10.7 h1:7rix8v8GpI3ZBb0nSozFRgbtXKv+hOe+qfEpZqybrAg=
github.com/klauspost/compress v1.10.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
github.com/savsgio/gotils v0.0.0-20200909101946-939aa3fc74fb h1:XPJCVf85HPE2jMVEQ7QWrazaZo1lc94GbUWaQ8Yv5sM=
github.com/savsgio/gotils v0.0.0-20200909101946-939aa3fc74fb/go.mod h1:TWNAOTaVzGOXq8RbEvHnhzA/A2sLZzgn0m6URjnukY8=
github.com/savsgio/gotils v0.0.0-20210105085219-0567298fdcac h1:5pr1F6tcjeIKPKlrQZW6hzB0WxZge7SkkYVGG/e5pLY=
github.com/savsgio/gotils v0.0.0-20210105085219-0567298fdcac/go.mod h1:TWNAOTaVzGOXq8RbEvHnhzA/A2sLZzgn0m6URjnukY8=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.18.0 h1:IV0DdMlatq9QO1Cr6wGJPVW1sV1Q8HvZXAIcjorylyM=
github.com/valyala/fasthttp v1.18.0/go.mod h1:jjraHZVbKOXftJfsOYoAjaeygpj5hr8ermTRJNroD7A=
github.com/valyala/fasthttp v1.19.0 h1:PfTS4PeH3xDr3WomrDS2ID8lU2GskK1xS3YG6gIpibU=
github.com/valyala/fasthttp v1.19.0/go.mod h1:jjraHZVbKOXftJfsOYoAjaeygpj5hr8ermTRJNroD7A=
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a h1:0R4NLDRDZX6JcmhJgXi5E4b8Wg84ihbmUKp/GvSPEzc=
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down
8 changes: 4 additions & 4 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"

fastrouter "github.com/fasthttp/router"
"github.com/savsgio/gotils"
gstrings "github.com/savsgio/gotils/strings"
"github.com/valyala/fasthttp"
"github.com/valyala/fasthttp/fasthttpadaptor"
)
Expand All @@ -23,7 +23,7 @@ func buildOptionsView(url string, fn View, paths map[string][]string) View {
allow := make([]string, 0)

for method, urls := range paths {
if method == fasthttp.MethodOptions || !gotils.StringSliceInclude(urls, url) {
if method == fasthttp.MethodOptions || !gstrings.Include(urls, url) {
continue
}

Expand Down Expand Up @@ -150,7 +150,7 @@ func (r *Router) handlePath(p *Path) {
case p.registered:
r.mutable(true)
case isOPTIONS:
mutable := !gotils.StringSliceInclude(r.customOPTIONS, p.url)
mutable := !gstrings.Include(r.customOPTIONS, p.url)
r.mutable(mutable)
case r.routerMutable:
r.mutable(false)
Expand All @@ -159,7 +159,7 @@ func (r *Router) handlePath(p *Path) {
view := p.view
if isOPTIONS {
view = buildOptionsView(p.url, view, r.ListPaths())
r.customOPTIONS = gotils.StringUniqueAppend(r.customOPTIONS, p.url)
r.customOPTIONS = gstrings.UniqueAppend(r.customOPTIONS, p.url)
}

handler := r.handler(view, p.middlewares)
Expand Down
4 changes: 2 additions & 2 deletions utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"runtime"
"testing"

"github.com/savsgio/gotils"
"github.com/savsgio/gotils/bytes"
"github.com/valyala/fasthttp"
)

Expand Down Expand Up @@ -89,7 +89,7 @@ func Test_chmodFileToSocket(t *testing.T) {
t.Skip()
}

filepath := "/tmp/atreugo-test-" + string(gotils.RandBytes(make([]byte, 10))) + ".sock"
filepath := "/tmp/atreugo-test-" + string(bytes.Rand(make([]byte, 10))) + ".sock"

f, err := os.Create(filepath)
if err != nil {
Expand Down

0 comments on commit ad78503

Please sign in to comment.