mirror of
https://github.com/kataras/iris.git
synced 2026-01-09 13:05:56 +00:00
performance close to handlers if no bindings but even if bindings except service (new feature is that we can bind functions as well) is x1.1 faster than the previous mvc implementation - make BaseController (so and C) optionally but not break the existing APIs that using iris.C or mvc.C
Former-commit-id: a26a8f836894c061e0f435df8ac1c2c534f0ee48
This commit is contained in:
23
_benchmarks/iris-mvc2/controllers/values_controller.go
Normal file
23
_benchmarks/iris-mvc2/controllers/values_controller.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package controllers
|
||||
|
||||
// ValuesController is the equivalent
|
||||
// `ValuesController` of the .net core 2.0 mvc application.
|
||||
type ValuesController struct{}
|
||||
|
||||
/* on windows tests(older) the Get was:
|
||||
func (vc *ValuesController) Get() {
|
||||
// id,_ := vc.Params.GetInt("id")
|
||||
// vc.Ctx.WriteString("value")
|
||||
}
|
||||
but as Iris is always going better, now supports return values as well*/
|
||||
|
||||
// Get handles "GET" requests to "api/values/{id}".
|
||||
func (vc *ValuesController) Get() string {
|
||||
return "value"
|
||||
}
|
||||
|
||||
// Put handles "PUT" requests to "api/values/{id}".
|
||||
func (vc *ValuesController) Put() {}
|
||||
|
||||
// Delete handles "DELETE" requests to "api/values/{id}".
|
||||
func (vc *ValuesController) Delete() {}
|
||||
17
_benchmarks/iris-mvc2/main.go
Normal file
17
_benchmarks/iris-mvc2/main.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
/// TODO: remove this on the "master" branch, or even replace it
|
||||
// with the "iris-mvc" (the new implementatioin is even faster, close to handlers version,
|
||||
// with bindings or without).
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/_benchmarks/iris-mvc2/controllers"
|
||||
"github.com/kataras/iris/mvc2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := iris.New()
|
||||
mvc2.New().Controller(app.Party("/api/values/{id}"), new(controllers.ValuesController))
|
||||
app.Run(iris.Addr(":5000"), iris.WithoutVersionChecker)
|
||||
}
|
||||
Reference in New Issue
Block a user