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

Function main

_examples/http-server/custom-httpserver/multi/main.go:9–47  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7)
8
9func main() {
10 app := iris.New()
11
12 app.Get("/", func(ctx iris.Context) {
13 ctx.Writef("Hello from the server")
14 })
15
16 app.Get("/mypath", func(ctx iris.Context) {
17 ctx.Writef("Hello from %s", ctx.Path())
18 })
19
20 // Note: It's not needed if the first action is "go app.Run".
21 if err := app.Build(); err != nil {
22 panic(err)
23 }
24
25 // start a secondary server listening on localhost:9090.
26 // use "go" keyword for Listen functions if you need to use more than one server at the same app.
27 //
28 // http://localhost:9090/
29 // http://localhost:9090/mypath
30 srv1 := &http.Server{Addr: ":9090", Handler: app}
31 go srv1.ListenAndServe()
32 println("Start a server listening on http://localhost:9090")
33
34 // start a "second-secondary" server listening on localhost:5050.
35 //
36 // http://localhost:5050/
37 // http://localhost:5050/mypath
38 srv2 := &http.Server{Addr: ":5050", Handler: app}
39 go srv2.ListenAndServe()
40 println("Start a server listening on http://localhost:5050")
41
42 // Note: app.Run is totally optional, we have already built the app with app.Build,
43 // you can just make a new http.Server instead.
44 // http://localhost:8080/
45 // http://localhost:8080/mypath
46 app.Listen(":8080") // Block here.
47}

Callers

nothing calls this directly

Calls 7

NewMethod · 0.80
WritefMethod · 0.80
ListenAndServeMethod · 0.80
GetMethod · 0.65
PathMethod · 0.65
BuildMethod · 0.65
ListenMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…