mirror of
https://github.com/kataras/iris.git
synced 2026-01-24 04:15:56 +00:00
❤️ awesome and unique features for end-developers are coming...
total refactor of the hero and mvc packages, see README#Next (it's not completed yet) Former-commit-id: b85ae99cbfe5965ba919c1e15cf4989e787982c0
This commit is contained in:
38
_benchmarks/_internal/v12.1.x/di.go
Normal file
38
_benchmarks/_internal/v12.1.x/di.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris/v12"
|
||||
"github.com/kataras/iris/v12/hero"
|
||||
)
|
||||
|
||||
type (
|
||||
testInput struct {
|
||||
Email string `json:"email"`
|
||||
}
|
||||
|
||||
testOutput struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
)
|
||||
|
||||
func handler(id int, in testInput) testOutput {
|
||||
return testOutput{
|
||||
ID: id,
|
||||
Name: in.Email,
|
||||
}
|
||||
}
|
||||
|
||||
func dependency(ctx iris.Context) (in testInput, err error) {
|
||||
err = ctx.ReadJSON(&in)
|
||||
return
|
||||
}
|
||||
|
||||
func main() {
|
||||
app := iris.New()
|
||||
|
||||
c := hero.New()
|
||||
c.Register(dependency)
|
||||
app.Post("/{id:int}", c.Handler(handler))
|
||||
app.Listen(":5000", iris.WithOptimizations)
|
||||
}
|
||||
15
_benchmarks/_internal/v12.1.x/di_test.go
Normal file
15
_benchmarks/_internal/v12.1.x/di_test.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/kataras/iris/v12/hero"
|
||||
)
|
||||
|
||||
func BenchmarkHero(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
c := hero.New()
|
||||
c.Register(dependency)
|
||||
_ = c.Handler(handler)
|
||||
}
|
||||
}
|
||||
BIN
_benchmarks/_internal/v12.1.x/di_test.txt
Normal file
BIN
_benchmarks/_internal/v12.1.x/di_test.txt
Normal file
Binary file not shown.
8
_benchmarks/_internal/v12.1.x/go.mod
Normal file
8
_benchmarks/_internal/v12.1.x/go.mod
Normal file
@@ -0,0 +1,8 @@
|
||||
module myoldapp
|
||||
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/kataras/iris/v12 v12.1.8
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
|
||||
)
|
||||
Reference in New Issue
Block a user