mirror of
https://github.com/kataras/iris.git
synced 2026-01-20 18:35:57 +00:00
websocket: replace sync.Map with custom map[string]*connection. Add translate template function example. Fix ctx.HandlerName() does not return the end-dev-defined current route's name, this will give better warnings when using MVC in a wrong way
Former-commit-id: 38fda8a20da9bc7665cdd209b7b367c1337dbd94
This commit is contained in:
@@ -59,6 +59,19 @@ func newApp() *iris.Application {
|
||||
"key2", fromSecondFileValue)
|
||||
})
|
||||
|
||||
// using in inside your templates:
|
||||
view := iris.HTML("./templates", ".html")
|
||||
app.RegisterView(view)
|
||||
|
||||
app.Get("/templates", func(ctx iris.Context) {
|
||||
ctx.View("index.html", iris.Map{
|
||||
"tr": ctx.Translate,
|
||||
})
|
||||
// it will return "hello, iris"
|
||||
// when {{call .tr "hi" "iris"}}
|
||||
})
|
||||
//
|
||||
|
||||
return app
|
||||
}
|
||||
|
||||
|
||||
1
_examples/miscellaneous/i18n/templates/index.html
Normal file
1
_examples/miscellaneous/i18n/templates/index.html
Normal file
@@ -0,0 +1 @@
|
||||
{{call .tr "hi" "iris"}}
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/kataras/iris"
|
||||
"github.com/kataras/iris/middleware/recover"
|
||||
"github.com/kataras/iris/sessions"
|
||||
|
||||
"github.com/kataras/iris/mvc"
|
||||
@@ -11,6 +12,7 @@ import (
|
||||
|
||||
func main() {
|
||||
app := iris.New()
|
||||
app.Use(recover.New())
|
||||
app.Logger().SetLevel("debug")
|
||||
mvc.Configure(app.Party("/basic"), basicMVC)
|
||||
|
||||
|
||||
4
_examples/websocket/custom-go-client/run.bat
Normal file
4
_examples/websocket/custom-go-client/run.bat
Normal file
@@ -0,0 +1,4 @@
|
||||
@echo off
|
||||
REM run.bat 30
|
||||
start go run main.go server
|
||||
for /L %%n in (1,1,%1) do start go run main.go client
|
||||
Reference in New Issue
Block a user