mirror of https://github.com/gofiber/fiber.git
Golint code
parent
6e0595ee25
commit
b8228e4546
6
app.go
6
app.go
|
@ -120,7 +120,7 @@ func New(settings ...*Settings) *App {
|
|||
// Create app
|
||||
app := new(App)
|
||||
// Create route stack
|
||||
app.routes = make([][]*Route, len(methodINT), len(methodINT))
|
||||
app.routes = make([][]*Route, len(methodINT))
|
||||
// Create settings
|
||||
app.Settings = new(Settings)
|
||||
// Set default settings
|
||||
|
@ -456,9 +456,7 @@ func (app *App) Test(request *http.Request, msTimeout ...int) (*http.Response, e
|
|||
}
|
||||
} else {
|
||||
// Without timeout
|
||||
select {
|
||||
case err = <-channel:
|
||||
}
|
||||
err = <-channel
|
||||
}
|
||||
// Check for errors
|
||||
if err != nil {
|
||||
|
|
|
@ -334,11 +334,11 @@ func Benchmark_Ctx_JSON(b *testing.B) {
|
|||
Name: "Grame",
|
||||
Age: 20,
|
||||
}
|
||||
|
||||
var err error
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.JSON(data)
|
||||
err = c.JSON(data)
|
||||
}
|
||||
|
||||
assertEqual(b, nil, err)
|
||||
assertEqual(b, `{"Name":"Grame","Age":20}`, string(c.Fasthttp.Response.Body()))
|
||||
}
|
||||
|
||||
|
@ -355,11 +355,12 @@ func Benchmark_Ctx_JSONP(b *testing.B) {
|
|||
Name: "Grame",
|
||||
Age: 20,
|
||||
}
|
||||
|
||||
var err error
|
||||
for n := 0; n < b.N; n++ {
|
||||
c.JSONP(data, "john")
|
||||
err = c.JSONP(data, "john")
|
||||
}
|
||||
|
||||
assertEqual(b, nil, err)
|
||||
assertEqual(b, `john({"Name":"Grame","Age":20});`, string(c.Fasthttp.Response.Body()))
|
||||
}
|
||||
|
||||
|
|
|
@ -62,18 +62,18 @@ func (app *App) nextRoute(ctx *Ctx) {
|
|||
|
||||
func (r *Route) matchRoute(path string) (match bool, values []string) {
|
||||
if r.use {
|
||||
if r.root == true || strings.HasPrefix(path, r.Path) {
|
||||
if r.root || strings.HasPrefix(path, r.Path) {
|
||||
return true, values
|
||||
}
|
||||
// Check for a simple path match
|
||||
} else if len(r.Path) == len(path) && r.Path == path {
|
||||
return true, values
|
||||
// Middleware routes allow prefix matches
|
||||
} else if r.root == true && path == "/" {
|
||||
} else if r.root && path == "/" {
|
||||
return true, values
|
||||
}
|
||||
// '*' wildcard matches any path
|
||||
if r.star == true {
|
||||
if r.star {
|
||||
return true, []string{path}
|
||||
}
|
||||
// Does this route have parameters
|
||||
|
|
6
utils.go
6
utils.go
|
@ -732,7 +732,7 @@ type paramSeg struct {
|
|||
IsLast bool
|
||||
}
|
||||
|
||||
var paramsDummy = make([]string, 100, 100)
|
||||
var paramsDummy = make([]string, 100)
|
||||
|
||||
const wildcardParam string = "*"
|
||||
|
||||
|
@ -763,7 +763,7 @@ func getParams(pattern string) (p parsedParams) {
|
|||
params = append(params, out[segIndex].Param)
|
||||
} else {
|
||||
// combine const segments
|
||||
if segIndex > 0 && out[segIndex-1].IsParam == false {
|
||||
if segIndex > 0 && !out[segIndex-1].IsParam {
|
||||
segIndex--
|
||||
out[segIndex].Const += "/" + aPattern[i]
|
||||
// create new const segment
|
||||
|
@ -812,7 +812,7 @@ func (p *parsedParams) getMatch(s string, partialCheck bool) ([]string, bool) {
|
|||
i = partLen
|
||||
}
|
||||
|
||||
if false == segment.IsOptional && i == 0 {
|
||||
if !segment.IsOptional && i == 0 {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue