MCPcopy Create free account
hub / github.com/kataras/iris / newApp

Function newApp

_examples/routing/main.go:94–128  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

92}
93
94func 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
130func h(ctx iris.Context) {
131 method := ctx.Method() // the http method requested a server's resource.

Callers 2

TestRoutingFunction · 0.70
mainFunction · 0.70

Calls 14

registerErrorsFunction · 0.85
registerGamesRoutesFunction · 0.85
registerSubdomainsFunction · 0.85
NewMethod · 0.80
GetBodyMethod · 0.80
WritefMethod · 0.80
PostValueDefaultMethod · 0.80
GetHeaderMethod · 0.80
HandleMethod · 0.65
PostMethod · 0.65
StatusCodeMethod · 0.65
ErrorMethod · 0.65

Tested by 1

TestRoutingFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…