Initial Dever 0.0.1
This commit is contained in:
commit
81233d098c
1479 files changed
+163782
No files matched your search
@@ -0,0 +1,46 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
func main() {
|
||||
capacity, err := strconv.Atoi(os.Args[1])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
runtime.GOMAXPROCS(2)
|
||||
app := fiber.New(fiber.Config{
|
||||
Concurrency: capacity,
|
||||
BodyLimit: 65536,
|
||||
ReadBufferSize: 8192,
|
||||
ReadTimeout: 5 * time.Second,
|
||||
WriteTimeout: 5 * time.Second,
|
||||
IdleTimeout: 5 * time.Second,
|
||||
CaseSensitive: true,
|
||||
StrictRouting: true,
|
||||
})
|
||||
app.Get("/json", func(context fiber.Ctx) error {
|
||||
context.Set("Content-Type", "application/json")
|
||||
return context.SendString(`{"ok":true}`)
|
||||
})
|
||||
app.Post("/echo", func(context fiber.Ctx) error {
|
||||
context.Set("Content-Type", "application/octet-stream")
|
||||
return context.Send(context.BodyRaw())
|
||||
})
|
||||
bound, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("READY|%d\n", bound.Addr().(*net.TCPAddr).Port)
|
||||
if err := app.Listener(bound, fiber.ListenConfig{DisableStartupMessage: true}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user