Closed ericmdantas closed 8 years ago
In echo, it's much more straight forward:
package main
import (
"fmt"
"net/http"
"github.com/labstack/echo"
"github.com/labstack/echo/engine/fasthttp"
"github.com/labstack/echo/middleware"
)
type U struct {
N string `json:"name"`
}
func main() {
port := ":3000"
fmt.Println(port)
e := echo.New()
e.Use(middleware.Static(""))
e.Use(middleware.Static("client/dev"))
e.Get("/api", func(c echo.Context) error {
u := U{N: "abcdef"}
return c.JSON(http.StatusOK, u)
})
e.Run(fasthttp.New(port))
}
I'll create a branch today to get this fixed.
Not to mention the performance gains and less memory consumption.
Summary:
Total: 8.1996 secs
Slowest: 4.1480 secs
Fastest: 0.0000 secs
Average: 0.7304 secs
Requests/sec: 11895.0840
Total data: 292605 bytes
Size/request: 3 bytes
Status code distribution:
[200] 97535 responses
Response time histogram:
0.000 [973] |
0.415 [21650] |∎∎∎∎∎∎∎∎∎∎∎∎∎∎
0.830 [60268] |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
1.244 [3595] |∎∎
1.659 [2181] |∎
2.074 [791] |
2.489 [2108] |∎
2.904 [1114] |
3.318 [1323] |
3.733 [2024] |∎
4.148 [1508] |∎
Latency distribution:
10% in 0.3729 secs
25% in 0.4181 secs
50% in 0.4714 secs
75% in 0.6402 secs
90% in 1.4152 secs
95% in 2.8625 secs
99% in 3.8576 secs
Summary:
Total: 6.1480 secs
Slowest: 4.2820 secs
Fastest: 0.0000 secs
Average: 0.5517 secs
Requests/sec: 16265.4522
Total data: 300000 bytes
Size/request: 3 bytes
Status code distribution:
[200] 100000 responses
Response time histogram:
0.000 [46] |
0.428 [84535] |∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
0.856 [4460] |∎∎
1.285 [784] |
1.713 [190] |
2.141 [61] |
2.569 [1388] |
2.997 [2737] |∎
3.426 [2669] |∎
3.854 [3021] |∎
4.282 [109] |
Latency distribution:
10% in 0.1150 secs
25% in 0.2090 secs
50% in 0.2720 secs
75% in 0.3130 secs
90% in 1.5290 secs
95% in 3.0630 secs
99% in 3.6690 secs
Use new way to serve static stuff, from: middleware.Static(PATH)
to echo.Static(PATH)
.
The import changed too, from: github.com/labstack/echo/middleware
to github.com/labstack/echo
.
Commit: https://github.com/labstack/echo/issues/457.
Edit: It is still middleware
, the owner reverted the commit.
Depends on: https://github.com/labstack/echo/issues/459.
Merged go-echo
into master
and deleted branch go-echo
.
Http/2 is only available in standard server in echo.
See the FAQ in fasthttp for more info.
And, done!
1.7.2
released.
From httprouter to echo.
endpoint
subgenerator