()
| 92 | } |
| 93 | |
| 94 | func newApp() *iris.Application { |
| 95 | app := iris.New() |
| 96 | |
| 97 | registerErrors(app) |
| 98 | registerGamesRoutes(app) |
| 99 | registerSubdomains(app) |
| 100 | |
| 101 | app.Handle("GET", "/healthcheck", h) |
| 102 | |
| 103 | // "POST" method |
| 104 | // this handler reads raw body from the client/request |
| 105 | // and sends back the same body |
| 106 | // remember, we have limit to that body in order |
| 107 | // to protect ourselves from "over heating". |
| 108 | app.Post("/", iris.LimitRequestBodySize(maxBodySize), func(ctx iris.Context) { |
| 109 | // get request body |
| 110 | b, err := ctx.GetBody() |
| 111 | // if is larger then send a bad request status |
| 112 | if err != nil { |
| 113 | ctx.StatusCode(iris.StatusBadRequest) |
| 114 | ctx.Writef(err.Error()) |
| 115 | return |
| 116 | } |
| 117 | // send back the post body |
| 118 | ctx.Write(b) |
| 119 | }) |
| 120 | |
| 121 | app.HandleMany("POST PUT", "/postvalue", func(ctx iris.Context) { |
| 122 | name := ctx.PostValueDefault("name", "iris") |
| 123 | headervale := ctx.GetHeader("headername") |
| 124 | ctx.Writef("Hello %s | %s", name, headervale) |
| 125 | }) |
| 126 | |
| 127 | return app |
| 128 | } |
| 129 | |
| 130 | func h(ctx iris.Context) { |
| 131 | method := ctx.Method() // the http method requested a server's resource. |
searching dependent graphs…