Skip to content

Commit 0d26f24

Browse files
committed
examples: replace all app.Run(iris.Addr(...)) with app.Listen just for the shake of simplicity, both are doing the same exact thing as it's described on the http listening first example.
Former-commit-id: d20afb2e899aee658a8e0ed1693357798df93462
1 parent b6445c7 commit 0d26f24

File tree

182 files changed

+202
-227
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+202
-227
lines changed

README_ES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func main() {
3333
})
3434
})
3535

36-
app.Run(iris.Addr(":8080"))
36+
app.Listen(":8080")
3737
}
3838
```
3939

README_FA.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func main() {
4848
})
4949
})
5050

51-
app.Run(iris.Addr(":8080"))
51+
app.Listen(":8080")
5252
}
5353
```
5454

README_GR.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func main() {
3333
})
3434
})
3535

36-
app.Run(iris.Addr(":8080"))
36+
app.Listen(":8080")
3737
}
3838
```
3939

README_KO.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func main() {
3131
})
3232
})
3333

34-
app.Run(iris.Addr(":8080"))
34+
app.Listen(":8080")
3535
}
3636
```
3737

README_RU.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func main() {
3131
})
3232
})
3333

34-
app.Run(iris.Addr(":8080"))
34+
app.Listen(":8080")
3535
}
3636
```
3737

README_ZH.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func main() {
3131
})
3232
})
3333

34-
app.Run(iris.Addr(":8080"))
34+
app.Listen(":8080")
3535
}
3636
```
3737

_benchmarks/iris-mvc-templates/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func main() {
2424

2525
mvc.New(app).Handle(new(controllers.HomeController))
2626

27-
app.Run(iris.Addr(":5000"))
27+
app.Listen(":5000")
2828
}
2929

3030
type err struct {

_benchmarks/iris-sessions/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func main() {
2424
app.Delete("/del", delHandler)
2525
*/
2626

27-
app.Run(iris.Addr(":5000"))
27+
app.Listen(":5000")
2828
}
2929

3030
// Set and Get

_examples/README_ZH.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ import (
153153
func main() {
154154
app := iris.New()
155155
mvc.Configure(app.Party("/root"), myMVC)
156-
app.Run(iris.Addr(":8080"))
156+
app.Listen(":8080")
157157
}
158158

159159
func myMVC(app *mvc.Application) {

_examples/apidoc/yaag/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,5 @@ func main() {
5151
//
5252
// Example usage:
5353
// Visit all paths and open the generated "apidoc.html" file to see the API's automated docs.
54-
app.Run(iris.Addr(":8080"))
54+
app.Listen(":8080")
5555
}

_examples/authentication/basicauth/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func newApp() *iris.Application {
4545
func main() {
4646
app := newApp()
4747
// open http://localhost:8080/admin
48-
app.Run(iris.Addr(":8080"))
48+
app.Listen(":8080")
4949
}
5050

5151
func h(ctx iris.Context) {

_examples/authentication/oauth2/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ func main() {
400400
})
401401

402402
// http://localhost:3000
403-
app.Run(iris.Addr("localhost:3000"))
403+
app.Listen("localhost:3000")
404404
}
405405

406406
type ProviderIndex struct {

_examples/cache/client-side/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func main() {
3030
// })
3131

3232
app.Get("/", greet)
33-
app.Run(iris.Addr(":8080"))
33+
app.Listen(":8080")
3434
}
3535

3636
func greet(ctx iris.Context) {

_examples/cache/simple/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func main() {
6363
// saves its content on the first request and serves it instead of re-calculating the content.
6464
// After 10 seconds it will be cleared and reset.
6565

66-
app.Run(iris.Addr(":8080"))
66+
app.Listen(":8080")
6767
}
6868

6969
func writeMarkdown(ctx iris.Context) {

_examples/configuration/README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func main() {
2626
// [...]
2727

2828
// Good when you want to modify the whole configuration.
29-
app.Run(iris.Addr(":8080"), iris.WithConfiguration(iris.Configuration{
29+
app.Listen(":8080", iris.WithConfiguration(iris.Configuration{
3030
DisableStartupLog: false,
3131
DisableInterruptHandler: false,
3232
DisablePathCorrection: false,
@@ -60,11 +60,11 @@ func main() {
6060
// Prefix: "With", code editors will help you navigate through all
6161
// configuration options without even a glitch to the documentation.
6262

63-
app.Run(iris.Addr(":8080"), iris.WithoutStartupLog, iris.WithCharset("UTF-8"))
63+
app.Listen(":8080", iris.WithoutStartupLog, iris.WithCharset("UTF-8"))
6464

6565
// or before run:
6666
// app.Configure(iris.WithoutStartupLog, iris.WithCharset("UTF-8"))
67-
// app.Run(iris.Addr(":8080"))
67+
// app.Listen(":8080")
6868
}
6969
```
7070

@@ -99,7 +99,7 @@ func main() {
9999
// [...]
100100

101101
// Good when you have two configurations, one for development and a different one for production use.
102-
app.Run(iris.Addr(":8080"), iris.WithConfiguration(iris.TOML("./configs/iris.tml")))
102+
app.Listen(":8080", iris.WithConfiguration(iris.TOML("./configs/iris.tml")))
103103
}
104104
```
105105

@@ -129,7 +129,7 @@ func main() {
129129
})
130130
// [...]
131131

132-
app.Run(iris.Addr(":8080"), iris.WithConfiguration(iris.YAML("./configs/iris.yml")))
132+
app.Listen(":8080", iris.WithConfiguration(iris.YAML("./configs/iris.yml")))
133133
}
134134

135135
```
@@ -141,7 +141,7 @@ func main() {
141141
// from the main application's `Run` function.
142142
//
143143
// Usage:
144-
// err := app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed))
144+
// err := app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed))
145145
// will return `nil` if the server's error was `http/iris#ErrServerClosed`.
146146
//
147147
// See `Configuration#IgnoreServerErrors []string` too.
@@ -278,6 +278,6 @@ func main() {
278278
app := iris.New()
279279
app.Configure(counter.Configurator)
280280

281-
app.Run(iris.Addr(":8080"))
281+
app.Listen(":8080")
282282
}
283283
```

_examples/configuration/from-configuration-structure/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func main() {
1212
// [...]
1313

1414
// Good when you want to modify the whole configuration.
15-
app.Run(iris.Addr(":8080"), iris.WithConfiguration(iris.Configuration{ // default configuration:
15+
app.Listen(":8080", iris.WithConfiguration(iris.Configuration{ // default configuration:
1616
DisableStartupLog: false,
1717
DisableInterruptHandler: false,
1818
DisablePathCorrection: false,

_examples/configuration/from-toml-file/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ func main() {
1313
// [...]
1414

1515
// Good when you have two configurations, one for development and a different one for production use.
16-
app.Run(iris.Addr(":8080"), iris.WithConfiguration(iris.TOML("./configs/iris.tml")))
16+
app.Listen(":8080", iris.WithConfiguration(iris.TOML("./configs/iris.tml")))
1717

1818
// or before run:
1919
// app.Configure(iris.WithConfiguration(iris.TOML("./configs/iris.tml")))
20-
// app.Run(iris.Addr(":8080"))
20+
// app.Listen(":8080")
2121
}

_examples/configuration/from-yaml-file/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ func main() {
1414
// Good when you have two configurations, one for development and a different one for production use.
1515
// If iris.YAML's input string argument is "~" then it loads the configuration from the home directory
1616
// and can be shared between many iris instances.
17-
app.Run(iris.Addr(":8080"), iris.WithConfiguration(iris.YAML("./configs/iris.yml")))
17+
app.Listen(":8080", iris.WithConfiguration(iris.YAML("./configs/iris.yml")))
1818

1919
// or before run:
2020
// app.Configure(iris.WithConfiguration(iris.YAML("./configs/iris.yml")))
21-
// app.Run(iris.Addr(":8080"))
21+
// app.Listen(":8080")
2222
}

_examples/configuration/from-yaml-file/shared-configuration/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ func main() {
1414
// Good when you share configuration between multiple iris instances.
1515
// This configuration file lives in your $HOME/iris.yml for unix hosts
1616
// or %HOMEDRIVE%+%HOMEPATH%/iris.yml for windows hosts, and you can modify it.
17-
app.Run(iris.Addr(":8080"), iris.WithGlobalConfiguration)
17+
app.Listen(":8080", iris.WithGlobalConfiguration)
1818
// or before run:
1919
// app.Configure(iris.WithGlobalConfiguration)
20-
// app.Run(iris.Addr(":8080"))
20+
// app.Listen(":8080")
2121
}

_examples/configuration/functional/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ func main() {
1515
// Prefix: "With", code editors will help you navigate through all
1616
// configuration options without even a glitch to the documentation.
1717

18-
app.Run(iris.Addr(":8080"), iris.WithoutStartupLog, iris.WithCharset("UTF-8"))
18+
app.Listen(":8080", iris.WithoutStartupLog, iris.WithCharset("UTF-8"))
1919

2020
// or before run:
2121
// app.Configure(iris.WithoutStartupLog, iris.WithCharset("UTF-8"))
22-
// app.Run(iris.Addr(":8080"))
22+
// app.Listen(":8080")
2323
}

_examples/convert-handlers/negroni-like/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func main() {
2626

2727
// http://localhost:8080
2828
// http://localhost:8080/ok
29-
app.Run(iris.Addr(":8080"))
29+
app.Listen(":8080")
3030
}
3131

3232
func negronilikeTestMiddleware(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {

_examples/convert-handlers/nethttp/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func main() {
2323

2424
// http://localhost:8080
2525
// http://localhost:8080/ok
26-
app.Run(iris.Addr(":8080"))
26+
app.Listen(":8080")
2727
}
2828

2929
func nativeTestMiddleware(w http.ResponseWriter, r *http.Request) {

_examples/convert-handlers/real-usecase-raven/wrapping-the-router/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ func main() {
4141
irisRouter(w, r)
4242
})
4343

44-
app.Run(iris.Addr(":8080"))
44+
app.Listen(":8080")
4545
}

_examples/convert-handlers/real-usecase-raven/writing-middleware/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@ func main() {
5353
ctx.Writef("Hi")
5454
})
5555

56-
app.Run(iris.Addr(":8080"))
56+
app.Listen(":8080")
5757
}

_examples/cookies/basic/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@ func main() {
6060
// GET: http://localhost:8080/cookies/my_name/my_value
6161
// GET: http://localhost:8080/cookies/my_name
6262
// DELETE: http://localhost:8080/cookies/my_name
63-
app.Run(iris.Addr(":8080"))
63+
app.Listen(":8080")
6464
}

_examples/cookies/securecookie/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@ func newApp() *iris.Application {
5555

5656
func main() {
5757
app := newApp()
58-
app.Run(iris.Addr(":8080"))
58+
app.Listen(":8080")
5959
}

_examples/desktop-app/blink/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func runServer() {
2323
app.Get("/", func(ctx iris.Context) {
2424
ctx.HTML("<h1> Hello Desktop</h1>")
2525
})
26-
app.Run(iris.Addr(addr))
26+
app.Listen(addr)
2727
}
2828

2929
func showAndWaitWindow() {

_examples/desktop-app/lorca/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func runServer() {
2121
app.Get("/", func(ctx iris.Context) {
2222
ctx.HTML("<head><title>My App</title></head><body><h1>Hello Desktop</h1></body>")
2323
})
24-
app.Run(iris.Addr(addr))
24+
app.Listen(addr)
2525
}
2626

2727
func showAndWaitWindow() {

_examples/desktop-app/webview/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func runServer() {
3030
app.Get("/", func(ctx iris.Context) {
3131
ctx.HTML("<h1> Hello Desktop</h1>")
3232
})
33-
app.Run(iris.Addr(addr))
33+
app.Listen(addr)
3434
}
3535

3636
func showAndWaitWindow() {

_examples/docker/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ func main() {
2222
ctx.Writef("id: %d", ctx.Params().GetUintDefault("id", 0))
2323
})
2424

25-
app.Run(iris.Addr(*addr))
25+
app.Listen(*addr)
2626
}

_examples/experimental-handlers/casbin/middleware/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func newApp() *iris.Application {
3535

3636
func main() {
3737
app := newApp()
38-
app.Run(iris.Addr(":8080"))
38+
app.Listen(":8080")
3939
}
4040

4141
func hi(ctx iris.Context) {

_examples/experimental-handlers/casbin/wrapper/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func newApp() *iris.Application {
3535

3636
func main() {
3737
app := newApp()
38-
app.Run(iris.Addr(":8080"))
38+
app.Listen(":8080")
3939
}
4040

4141
func hi(ctx iris.Context) {

_examples/experimental-handlers/cloudwatch/simple/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ func main() {
4646
// http://localhost:8080
4747
// should give: NoCredentialProviders
4848
// which is correct, you have to authorize your aws, we asumme that you know how to.
49-
app.Run(iris.Addr(":8080"))
49+
app.Listen(":8080")
5050
}

_examples/experimental-handlers/cors/simple/client/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ func main() {
3434
// Start and navigate to http://localhost:8080
3535
// and go to the previous terminal of your running cors/simple/main.go server
3636
// and see the logs.
37-
app.Run(iris.Addr(":8080"))
37+
app.Listen(":8080")
3838
}

_examples/experimental-handlers/cors/simple/main.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ func main() {
4646

4747
// iris.WithoutPathCorrectionRedirection | iris#Configuration.DisablePathCorrectionRedirection:
4848
// CORS needs the allow origin headers in the redirect response as well, we have a solution for this:
49-
// If you use iris >= v11.0.4 then add the `app.Run(..., iris.WithoutPathCorrectionRedirection)`
50-
// on the server side if you wish
49+
// Add the iris.WithoutPathCorrectionRedirection option
5150
// to directly fire the handler instead of redirection (which is the default behavior)
5251
// on request paths like "/v1/mailer/" when "/v1/mailer" route handler is registered.
53-
app.Run(iris.Addr(":80"), iris.WithoutPathCorrectionRedirection)
52+
app.Listen(":80", iris.WithoutPathCorrectionRedirection)
5453
}

_examples/experimental-handlers/csrf/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func main() {
3535

3636
// GET: http://localhost:8080/user/signup
3737
// POST: http://localhost:8080/user/signup
38-
app.Run(iris.Addr(":8080"))
38+
app.Listen(":8080")
3939
}
4040

4141
func getSignupForm(ctx iris.Context) {

_examples/experimental-handlers/jwt/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ func main() {
5252

5353
app.Get("/", getTokenHandler)
5454
app.Get("/secured", j.Serve, myAuthenticatedHandler)
55-
app.Run(iris.Addr(":8080"))
55+
app.Listen(":8080")
5656
}

_examples/experimental-handlers/newrelic/simple/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ func main() {
2020
ctx.Writef("success!\n")
2121
})
2222

23-
app.Run(iris.Addr(":8080"))
23+
app.Listen(":8080")
2424
}

_examples/experimental-handlers/prometheus/simple/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ func main() {
3535
// http://localhost:8080/
3636
// http://localhost:8080/anotfound
3737
// http://localhost:8080/metrics
38-
app.Run(iris.Addr(":8080"))
38+
app.Listen(":8080")
3939
}

_examples/experimental-handlers/secure/simple/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ func main() {
3434
ctx.Writef("Hello from /home")
3535
})
3636

37-
app.Run(iris.Addr(":8080"))
37+
app.Listen(":8080")
3838
}

0 commit comments

Comments
 (0)