mirror of
https://github.com/kataras/iris.git
synced 2025-12-17 18:07:01 +00:00
OK, my dream-idea is implemented. TODO: Some examples and doc.go is not updated yet, comments on the mvc/di subpackage, the tutorial/vuejs-todo-mvc is running but not finished yet (it's using browser's localstorage and it should be replaced by the http requests that are registered via iris mvc
Former-commit-id: 0ea7e01ce1d78bcb78b40f3b0f5c03ad7c9abaea
This commit is contained in:
@@ -1,19 +1,8 @@
|
||||
package controllers
|
||||
|
||||
import "github.com/kataras/iris/mvc"
|
||||
|
||||
// ValuesController is the equivalent
|
||||
// `ValuesController` of the .net core 2.0 mvc application.
|
||||
type ValuesController struct {
|
||||
mvc.C
|
||||
}
|
||||
|
||||
/* 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*/
|
||||
type ValuesController struct{}
|
||||
|
||||
// Get handles "GET" requests to "api/values/{id}".
|
||||
func (vc *ValuesController) Get() string {
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
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/_benchmarks/iris-mvc2/controllers"
|
||||
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/_benchmarks/iris-mvc/controllers"
|
||||
"github.com/kataras/iris/mvc"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := iris.New()
|
||||
app.Controller("/api/values/{id}", new(controllers.ValuesController))
|
||||
|
||||
// 24 August 2017: Iris has a built'n version updater but we don't need it
|
||||
// when benchmarking...
|
||||
mvc.New(app.Party("/api/values/{id}")).Register(new(controllers.ValuesController))
|
||||
app.Run(iris.Addr(":5000"), iris.WithoutVersionChecker)
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package controllers
|
||||
|
||||
// import "github.com/kataras/iris/mvc2"
|
||||
|
||||
// ValuesController is the equivalent
|
||||
// `ValuesController` of the .net core 2.0 mvc application.
|
||||
type ValuesController struct{} //{ mvc2.C }
|
||||
|
||||
/* 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() {}
|
||||
@@ -1,17 +0,0 @@
|
||||
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)
|
||||
}
|
||||
@@ -1,13 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/context"
|
||||
)
|
||||
import "github.com/kataras/iris"
|
||||
|
||||
func main() {
|
||||
app := iris.New()
|
||||
app.Get("/api/values/{id}", func(ctx context.Context) {
|
||||
app.Get("/api/values/{id}", func(ctx iris.Context) {
|
||||
ctx.WriteString("value")
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user