From 0491aa68b5f7fa439d88189aa9e7a1741f1948ff Mon Sep 17 00:00:00 2001 From: "Gerasimos (Makis) Maropoulos" Date: Wed, 8 Aug 2018 14:58:37 +0300 Subject: [PATCH] add some more examples and screenshots about hero funcs on README.md Former-commit-id: 2703036228ec896edcffe322964e85680be09d23 --- README.md | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 00a6ca97..61a3668d 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,30 @@ func main() { $ go run example.go ``` +## Dependency Injection + +The package [hero](hero) contains features for binding any object or functions that `handlers` can use, these are called dependencies. + +With Iris you get truly safe bindings thanks to the [hero](_examples/hero) [package](hero). It is blazing-fast, near to raw handlers performance because Iris calculates everything before even server goes online! + +Below you will see some screenshots I prepared for you in order to be easier to understand: + +### 1. Path Parameters - Built'n Dependencies + +![](https://github.com/kataras/explore/raw/master/iris/hero/hero-1-monokai.png) + +### 2. Services - Static Dependencies + +![](https://github.com/kataras/explore/raw/master/iris/hero/hero-2-monokai.png) + +### 3. Per-Request - Dynamic Dependencies + +![](https://github.com/kataras/explore/raw/master/iris/hero/hero-3-monokai.png) + +`hero funcs` are very easy to understand and when you start using them **you never go back**. + +> With Iris you also get real and [blazing-fast](_benchmarks) [MVC support](_examples/mvc) which uses "hero" under the hoods. + ## API Examples ### Using Get, Post, Put, Patch, Delete and Options @@ -451,9 +475,12 @@ func main() { // Navigate to http://localhost:8080/ping // and open the ./logs{TODAY}.txt file. - if err := app.Run(iris.Addr(":8080"), iris.WithoutBanner, iris.WithoutServerError(iris.ErrServerClosed)); err != nil { - app.Logger().Warn("Shutdown with error: " + err.Error()) - } + app.Run( + iris.Addr(":8080"), + iris.WithoutBanner, + iris.WithoutVersionChecker, + iris.WithoutServerError(iris.ErrServerClosed), + ) } ``` @@ -613,11 +640,12 @@ func setupWebsocket(app *iris.Application) { ws.OnConnection(handleConnection) // register the server on an endpoint. - // see the inline javascript code in the websockets.html, this endpoint is used to connect to the server. + // see the inline javascript code in the websockets.html, + // this endpoint is used to connect to the server. app.Get("/echo", ws.Handler()) // serve the javascript built'n client-side library, // see websockets.html script tags, this path is used. - app.Any("/iris-ws.js",websocket.ClientHandler()) + app.Any("/iris-ws.js", websocket.ClientHandler()) } func handleConnection(c websocket.Connection) { @@ -639,7 +667,8 @@ func handleConnection(c websocket.Connection) { - + @@ -673,7 +702,7 @@ func handleConnection(c websocket.Connection) { function send() { addMessage("Me: " + input.value); // write ourselves - socket.Emit("chat", input.value);// send chat event data to the websocket server + socket.Emit("chat", input.value); // send chat event data to the websocket server input.value = ""; // clear the input }