diff --git a/Automatic-public-address.md b/Automatic-public-address.md
index e0d030c..8693762 100644
--- a/Automatic-public-address.md
+++ b/Automatic-public-address.md
@@ -20,7 +20,7 @@ Follow the steps below to, temporarily, convert your local Iris web server to a
Full `Tunneling` configuration:
```go
-app.Run(iris.Addr(":8080"), iris.WithConfiguration(
+app.Listen(":8080", iris.WithConfiguration(
iris.Configuration{
Tunneling: iris.TunnelingConfiguration{
AuthToken: "my-ngrok-auth-client-token",
diff --git a/Configuration.md b/Configuration.md
index e94def8..9bd2491 100644
--- a/Configuration.md
+++ b/Configuration.md
@@ -21,7 +21,7 @@ config := iris.WithConfiguration(iris.Configuration {
Charset: "UTF-8",
})
-app.Run(iris.Addr(":8080"), config)
+app.Listen(":8080", config)
```
### Load from [YAML](https://yaml.org/)
@@ -41,7 +41,7 @@ File: **main.go**
```go
config := iris.WithConfiguration(iris.YAML("./iris.yml"))
-app.Run(iris.Addr(":8080"), config)
+app.Listen(":8080", config)
```
### Load from [TOML](https://github.com/toml-lang/toml)
@@ -65,7 +65,7 @@ File: **main.go**
```go
config := iris.WithConfiguration(iris.TOML("./iris.tml"))
-app.Run(iris.Addr(":8080"), config)
+app.Listen(":8080", config)
```
## Using the functional way
@@ -73,7 +73,7 @@ app.Run(iris.Addr(":8080"), config)
As we already mention, you can pass any number of `iris.Configurator` in the `app.Run`’s second argument. Iris provides an option for each of its `iris.Configuration`’s fields.
```go
-app.Run(iris.Addr(":8080"), iris.WithoutInterruptHandler,
+app.Listen(":8080", iris.WithoutInterruptHandler,
iris.WithoutServerError(iris.ErrServerClosed),
iris.WithoutBodyConsumptionOnUnmarshal,
iris.WithoutAutoFireStatusCode,
@@ -91,7 +91,7 @@ configuration options without even a glitch to the documentation.
The `iris.Configuration` contains a field called `Other map[string]interface{}` which accepts any custom `key:value` option, therefore you can use that field to pass specific values that your app expects based on the custom requirements.
```go
-app.Run(iris.Addr(":8080"),
+app.Listen(":8080",
iris.WithOtherValue("ServerName", "my amazing iris server"),
iris.WithOtherValue("ServerOwner", "admin@example.com"),
)
diff --git a/File-server.md b/File-server.md
index a146e05..13e5b5d 100644
--- a/File-server.md
+++ b/File-server.md
@@ -48,7 +48,7 @@ app := iris.New()
app.HandleDir("/static", "./assets")
-app.Run(iris.Addr(":8080"))
+app.Listen(":8080")
```
Now, if you want to embed the static files to be lived inside the executable build in order to not depend on a system directory you can use a tool like [go-bindata](https://github.com/go-bindata/go-bindata) to convert the files into `[]byte` inside your program. Let's take a quick tutorial on this and how Iris helps to serve those data.
diff --git a/Forms.md b/Forms.md
index a0cc313..3794499 100644
--- a/Forms.md
+++ b/Forms.md
@@ -97,7 +97,7 @@ func main() {
})
})
- app.Run(iris.Addr(":8080"))
+ app.Listen(":8080")
}
```
@@ -125,7 +125,7 @@ func main() {
id, page, name, message)
})
- app.Run(iris.Addr(":8080"))
+ app.Listen(":8080")
}
```
@@ -183,7 +183,7 @@ func main() {
ctx.UploadFormFiles("./uploads", beforeSave)
})
- app.Run(iris.Addr(":8080"))
+ app.Listen(":8080")
}
func beforeSave(ctx iris.Context, file *multipart.FileHeader) {
diff --git a/Getting-started.md b/Getting-started.md
index 65f4634..406e6a1 100644
--- a/Getting-started.md
+++ b/Getting-started.md
@@ -19,7 +19,7 @@ func main() {
// Listens and serves incoming http requests
// on http://localhost:8080.
- app.Run(iris.Addr(":8080"))
+ app.Listen(":8080")
}
func myMiddleware(ctx iris.Context) {
@@ -75,7 +75,7 @@ func main() {
})
// Start the server using a network address.
- app.Run(iris.Addr(":8080"))
+ app.Listen(":8080")
}
```
diff --git a/HTTP-referer.md b/HTTP-referer.md
index 5020eab..dbfa765 100644
--- a/HTTP-referer.md
+++ b/HTTP-referer.md
@@ -71,7 +71,7 @@ func main() {
}
})
- app.Run(iris.Addr(":8080"))
+ app.Listen(":8080")
}
```
diff --git a/Host.md b/Host.md
index 8d32694..14c011c 100644
--- a/Host.md
+++ b/Host.md
@@ -8,8 +8,10 @@ by passing a network address with form of "hostname:ip". With Iris
we use the `iris.Addr` which is an `iris.Runner` type
```go
-// Listening on tcp with network address 0.0.0.0:8080
-app.Run(iris.Addr(":8080"))
+// Listening on tcp with network address 0.0.0.0:8080.
+//
+// Listen is a shortcut for app.Run(iris.Addr(":8080")).
+app.Listen(":8080")
```
Sometimes you have created a standard net/http server somewhere else in your app and want to use that to serve the Iris web app
@@ -165,7 +167,7 @@ app.ConfigureHost(func(h *iris.Supervisor) {
println("server terminated")
})
})
-app.Run(iris.Addr(":8080"))
+app.Listen(":8080")
```
Access to all hosts that serve your application can be provided by
@@ -200,7 +202,7 @@ app := iris.New()
app.Get("/", indexHandler)
// run in different goroutine in order to not block the main "goroutine".
-go app.Run(iris.Addr(":8080"))
+go app.Listen(":8080")
// start a second server which is listening on tcp 0.0.0.0:9090,
// without "go" keyword because we want to block at the last server-run.
app.NewHost(&http.Server{Addr:":9090"}).ListenAndServe()
@@ -245,7 +247,7 @@ func main() {
ctx.HTML("
hi, I just exist in order to see if the server is closed
")
})
- app.Run(iris.Addr(":8080"), iris.WithoutInterruptHandler)
+ app.Listen(":8080", iris.WithoutInterruptHandler)
}
```
diff --git a/Localization.md b/Localization.md
index 95c6566..0b56ee0 100644
--- a/Localization.md
+++ b/Localization.md
@@ -235,7 +235,7 @@ func main() {
// or http://localhost:8080/other?lang=en-US
//
// or use cookies to set the language.
- app.Run(iris.Addr(":8080"), iris.WithSitemap("http://localhost:8080"))
+ app.Listen(":8080", iris.WithSitemap("http://localhost:8080"))
}
```
diff --git a/MVC.md b/MVC.md
index 88b16ab..b52b131 100644
--- a/MVC.md
+++ b/MVC.md
@@ -33,7 +33,7 @@ import (
func main() {
app := iris.New()
mvc.Configure(app.Party("/root"), myMVC)
- app.Run(iris.Addr(":8080"))
+ app.Listen(":8080")
}
func myMVC(app *mvc.Application) {
@@ -192,7 +192,7 @@ func main() {
// http://localhost:8080/ping
// http://localhost:8080/hello
// http://localhost:8080/custom_path
- app.Run(iris.Addr(":8080"))
+ app.Listen(":8080")
}
// ExampleController serves the "/", "/ping" and "/hello".
diff --git a/Model-validation.md b/Model-validation.md
index f9d2947..c83d123 100644
--- a/Model-validation.md
+++ b/Model-validation.md
@@ -91,7 +91,7 @@ func main() {
// [save user to database...]
})
- app.Run(iris.Addr(":8080"))
+ app.Listen(":8080")
}
func UserStructLevelValidation(sl validator.StructLevel) {
diff --git a/Request-authentication.md b/Request-authentication.md
index ff127ac..54b406b 100644
--- a/Request-authentication.md
+++ b/Request-authentication.md
@@ -65,7 +65,7 @@ func main(){
app.Get("/", getTokenHandler)
app.Get("/secured", j.Serve, myAuthenticatedHandler)
- app.Run(iris.Addr(":8080"))
+ app.Listen(":8080")
}
```
diff --git a/Routing-error-handlers.md b/Routing-error-handlers.md
index e126910..dea2cff 100644
--- a/Routing-error-handlers.md
+++ b/Routing-error-handlers.md
@@ -20,7 +20,7 @@ func main(){
// defaults to < 200 || >= 400:
// app.OnAnyErrorCode(handler)
app.Get("/", index)
- app.Run(iris.Addr(":8080"))
+ app.Listen(":8080")
}
func notFound(ctx iris.Context) {
diff --git a/Routing-middleware.md b/Routing-middleware.md
index 9cf527c..4420a35 100644
--- a/Routing-middleware.md
+++ b/Routing-middleware.md
@@ -15,7 +15,7 @@ func main() {
app := iris.New()
// or app.Use(before) and app.Done(after).
app.Get("/", before, mainHandler, after)
- app.Run(iris.Addr(":8080"))
+ app.Listen(":8080")
}
func before(ctx iris.Context) {
@@ -80,7 +80,7 @@ func main() {
app.UseGlobal(before)
app.DoneGlobal(after)
- app.Run(iris.Addr(":8080"))
+ app.Listen(":8080")
}
func before(ctx iris.Context) {
diff --git a/Routing-override-context.md b/Routing-override-context.md
index 8c5582c..fb65093 100644
--- a/Routing-override-context.md
+++ b/Routing-override-context.md
@@ -90,7 +90,7 @@ func main() {
ctx.View("hi.html")
})
- app.Run(iris.Addr(":8080"))
+ app.Listen(":8080")
}
// Should always print "($PATH) Handler is executing from 'MyContext'"
diff --git a/Routing-path-parameter-types.md b/Routing-path-parameter-types.md
index e077a8b..4b65622 100644
--- a/Routing-path-parameter-types.md
+++ b/Routing-path-parameter-types.md
@@ -156,7 +156,7 @@ func main() {
ctx.WriteString(message)
})
- app.Run(iris.Addr(":8080"))
+ app.Listen(":8080")
}
```
diff --git a/Routing-reverse-lookups.md b/Routing-reverse-lookups.md
index 74360a5..54829d8 100644
--- a/Routing-reverse-lookups.md
+++ b/Routing-reverse-lookups.md
@@ -25,7 +25,7 @@ func main() {
app.Get("/about", h).Name = "about"
app.Get("/page/{id}", h).Name = "page"
- app.Run(iris.Addr(":8080"))
+ app.Listen(":8080")
}
```
diff --git a/Routing-subdomains.md b/Routing-subdomains.md
index 9757abf..79c5e52 100644
--- a/Routing-subdomains.md
+++ b/Routing-subdomains.md
@@ -44,7 +44,7 @@ admin.Get("/hey", func(ctx iris.Context) {
// [other routes here...]
-app.Run(iris.Addr("mydomain.com:80"))
+app.Listen("mydomain.com:80")
```
For local development you'll have to edit your hosts, for example in windows operating system open the `C:\Windows\System32\Drivers\etc\hosts` file and append:
diff --git a/Routing-wrap-the-router.md b/Routing-wrap-the-router.md
index 0d0d736..5df9243 100644
--- a/Routing-wrap-the-router.md
+++ b/Routing-wrap-the-router.md
@@ -95,7 +95,7 @@ func main() {
// http://localhost:8080/css/main.css
// http://localhost:8080/profile/anyusername
// http://localhost:8080/other/random
- app.Run(iris.Addr(":8080"))
+ app.Listen(":8080")
// Note: In this example we just saw one use case,
// you may want to .WrapRouter or .Downgrade in order to
diff --git a/Routing.md b/Routing.md
index 1d31804..7c72e11 100644
--- a/Routing.md
+++ b/Routing.md
@@ -38,13 +38,13 @@ However, if you want to **disable path correction** for the requested resources
// [app := iris.New...]
// [...]
-app.Run(iris.Addr(":8080"), iris.WithoutPathCorrection)
+app.Listen(":8080", iris.WithoutPathCorrection)
```
If you want to keep the same handler and route for `/api/user` and `/api/user/` paths **without redirection**(common scenario) use just the `iris.WithoutPathCorrectionRedirection` option instead:
```go
-app.Run(iris.Addr(":8080"), iris.WithoutPathCorrectionRedirection)
+app.Listen(":8080", iris.WithoutPathCorrectionRedirection)
```
## API
@@ -165,7 +165,7 @@ func main() {
ctx.Exec("GET", "/invisible/iris")
})
- app.Run(iris.Addr(":8080"))
+ app.Listen(":8080")
}
```
diff --git a/Sessions.md b/Sessions.md
index 8da2aac..1a0bef4 100644
--- a/Sessions.md
+++ b/Sessions.md
@@ -185,7 +185,7 @@ func main() {
app.Get("/login", login)
app.Get("/logout", logout)
- app.Run(iris.Addr(":8080"))
+ app.Listen(":8080")
}
```
diff --git a/Sitemap.md b/Sitemap.md
index 807aff8..2e69db2 100644
--- a/Sitemap.md
+++ b/Sitemap.md
@@ -6,7 +6,7 @@ To enable sitemaps on your web application you should use the `iris.WithSitemap`
app := iris.New()
// [...]
-app.Run(iris.Addr(":8080"), iris.WithSitemap("http://localhost:8080"))
+app.Listen(":8080", iris.WithSitemap("http://localhost:8080"))
```
The application will loop through registered _static_ routes and it will add each one of them to the sitemap file. By default only the `` XML element will be filled unless the route's fields `LastMod`, `ChangeFreq` or/and `Priority`[*](https://www.sitemaps.org/protocol.html) are set.
diff --git a/Testing.md b/Testing.md
index 162f673..6a28979 100644
--- a/Testing.md
+++ b/Testing.md
@@ -51,7 +51,7 @@ func h(ctx iris.Context) {
func main() {
app := newApp()
- app.Run(iris.Addr(":8080"))
+ app.Listen(":8080")
}
```
diff --git a/View.md b/View.md
index 169a7ce..7ed1796 100644
--- a/View.md
+++ b/View.md
@@ -114,7 +114,7 @@ func main() {
ctx.View("hi.html")
})
- app.Run(iris.Addr(":8080"))
+ app.Listen(":8080")
}
```