mirror of https://github.com/gofiber/fiber.git
commit
e8c24762ce
2
app.go
2
app.go
|
@ -658,7 +658,7 @@ func (app *App) startupMessage(addr string, tls bool, pids string) {
|
|||
if app.IsChild() {
|
||||
return
|
||||
}
|
||||
//
|
||||
// ascii logo
|
||||
var logo string
|
||||
logo += `%s _______ __ %s` + "\n"
|
||||
logo += `%s ____%s / ____(_) /_ ___ _____ %s` + "\n"
|
||||
|
|
|
@ -639,6 +639,7 @@ func Test_App_Next_Method(t *testing.T) {
|
|||
utils.AssertEqual(t, 404, resp.StatusCode, "Status code")
|
||||
}
|
||||
|
||||
// go test -run Test_App_Listen
|
||||
func Test_App_Listen(t *testing.T) {
|
||||
app := New(&Settings{
|
||||
DisableStartupMessage: true,
|
||||
|
@ -658,6 +659,7 @@ func Test_App_Listen(t *testing.T) {
|
|||
utils.AssertEqual(t, nil, app.Listen("4010"))
|
||||
}
|
||||
|
||||
// go test -run Test_App_Listener
|
||||
func Test_App_Listener(t *testing.T) {
|
||||
app := New(&Settings{
|
||||
DisableStartupMessage: true,
|
||||
|
|
4
ctx.go
4
ctx.go
|
@ -257,7 +257,7 @@ func (ctx *Ctx) BodyParser(out interface{}) error {
|
|||
}
|
||||
// query params
|
||||
if ctx.Fasthttp.QueryArgs().Len() > 0 {
|
||||
log.Println("Converting querystring using BodyParser will be deprecated, please use ctx.QueryParser")
|
||||
fmt.Println("Parsing query strings using `BodyParser` is deprecated since v1.12.7, please us `ctx.QueryParser` instead")
|
||||
data := make(map[string][]string)
|
||||
ctx.Fasthttp.QueryArgs().VisitAll(func(key []byte, val []byte) {
|
||||
data[getString(key)] = append(data[getString(key)], getString(val))
|
||||
|
@ -642,7 +642,7 @@ func (ctx *Ctx) Next(err ...error) {
|
|||
|
||||
// OriginalURL contains the original request URL.
|
||||
// Returned value is only valid within the handler. Do not store any references.
|
||||
// Make copies or use the Immutable setting instead.
|
||||
// Make copies or use the Immutable setting to use the value outside the Handler.
|
||||
func (ctx *Ctx) OriginalURL() string {
|
||||
return getString(ctx.Fasthttp.Request.Header.RequestURI())
|
||||
}
|
||||
|
|
|
@ -1536,6 +1536,7 @@ func Benchmark_Ctx_SendBytes_B(b *testing.B) {
|
|||
utils.AssertEqual(b, []byte("Hello, world!"), c.Fasthttp.Response.Body())
|
||||
}
|
||||
|
||||
// go test -run Benchmark_Ctx_QueryParser
|
||||
func Test_Ctx_QueryParser(t *testing.T) {
|
||||
t.Parallel()
|
||||
app := New()
|
||||
|
@ -1554,6 +1555,7 @@ func Test_Ctx_QueryParser(t *testing.T) {
|
|||
utils.AssertEqual(t, 2, len(q.Hobby))
|
||||
}
|
||||
|
||||
// go test -v -run=^$ -bench=Benchmark_Ctx_QueryParser -benchmem -count=4
|
||||
func Benchmark_Ctx_QueryParser(b *testing.B) {
|
||||
app := New()
|
||||
ctx := app.AcquireCtx(&fasthttp.RequestCtx{})
|
||||
|
|
|
@ -60,14 +60,17 @@ func (app *App) prefork(addr string, tlsconfig ...*tls.Config) (err error) {
|
|||
_ = proc.Process.Kill()
|
||||
}
|
||||
}()
|
||||
|
||||
// collect child pids
|
||||
pids := []string{}
|
||||
|
||||
// launch child procs
|
||||
for i := 0; i < max; i++ {
|
||||
/* #nosec G204 */
|
||||
cmd := exec.Command(os.Args[0], os.Args[1:]...)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
|
||||
// add fiber prefork child flag into child proc env
|
||||
cmd.Env = append(os.Environ(),
|
||||
fmt.Sprintf("%s=%s", envPreforkChildKey, envPreforkChildVal),
|
||||
|
@ -75,9 +78,11 @@ func (app *App) prefork(addr string, tlsconfig ...*tls.Config) (err error) {
|
|||
if err = cmd.Start(); err != nil {
|
||||
return fmt.Errorf("failed to start a child prefork process, error: %v", err)
|
||||
}
|
||||
|
||||
// store child process
|
||||
childs[cmd.Process.Pid] = cmd
|
||||
pids = append(pids, strconv.Itoa(cmd.Process.Pid))
|
||||
|
||||
// notify master if child crashes
|
||||
go func() {
|
||||
channel <- child{cmd.Process.Pid, cmd.Wait()}
|
||||
|
|
Loading…
Reference in New Issue