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
This commit is contained in:
Gerasimos (Makis) Maropoulos 2020-03-05 22:41:27 +02:00
parent b6445c7238
commit 0d26f24eb7
182 changed files with 202 additions and 227 deletions

View File

@ -33,7 +33,7 @@ func main() {
}) })
}) })
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
``` ```

View File

@ -48,7 +48,7 @@ func main() {
}) })
}) })
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
``` ```

View File

@ -33,7 +33,7 @@ func main() {
}) })
}) })
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
``` ```

View File

@ -31,7 +31,7 @@ func main() {
}) })
}) })
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
``` ```

View File

@ -31,7 +31,7 @@ func main() {
}) })
}) })
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
``` ```

View File

@ -31,7 +31,7 @@ func main() {
}) })
}) })
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
``` ```

View File

@ -24,7 +24,7 @@ func main() {
mvc.New(app).Handle(new(controllers.HomeController)) mvc.New(app).Handle(new(controllers.HomeController))
app.Run(iris.Addr(":5000")) app.Listen(":5000")
} }
type err struct { type err struct {

View File

@ -24,7 +24,7 @@ func main() {
app.Delete("/del", delHandler) app.Delete("/del", delHandler)
*/ */
app.Run(iris.Addr(":5000")) app.Listen(":5000")
} }
// Set and Get // Set and Get

View File

@ -153,7 +153,7 @@ import (
func main() { func main() {
app := iris.New() app := iris.New()
mvc.Configure(app.Party("/root"), myMVC) mvc.Configure(app.Party("/root"), myMVC)
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
func myMVC(app *mvc.Application) { func myMVC(app *mvc.Application) {

View File

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

View File

@ -45,7 +45,7 @@ func newApp() *iris.Application {
func main() { func main() {
app := newApp() app := newApp()
// open http://localhost:8080/admin // open http://localhost:8080/admin
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
func h(ctx iris.Context) { func h(ctx iris.Context) {

View File

@ -400,7 +400,7 @@ func main() {
}) })
// http://localhost:3000 // http://localhost:3000
app.Run(iris.Addr("localhost:3000")) app.Listen("localhost:3000")
} }
type ProviderIndex struct { type ProviderIndex struct {

View File

@ -30,7 +30,7 @@ func main() {
// }) // })
app.Get("/", greet) app.Get("/", greet)
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
func greet(ctx iris.Context) { func greet(ctx iris.Context) {

View File

@ -63,7 +63,7 @@ func main() {
// saves its content on the first request and serves it instead of re-calculating the content. // saves its content on the first request and serves it instead of re-calculating the content.
// After 10 seconds it will be cleared and reset. // After 10 seconds it will be cleared and reset.
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
func writeMarkdown(ctx iris.Context) { func writeMarkdown(ctx iris.Context) {

View File

@ -26,7 +26,7 @@ func main() {
// [...] // [...]
// Good when you want to modify the whole configuration. // Good when you want to modify the whole configuration.
app.Run(iris.Addr(":8080"), iris.WithConfiguration(iris.Configuration{ app.Listen(":8080", iris.WithConfiguration(iris.Configuration{
DisableStartupLog: false, DisableStartupLog: false,
DisableInterruptHandler: false, DisableInterruptHandler: false,
DisablePathCorrection: false, DisablePathCorrection: false,
@ -60,11 +60,11 @@ func main() {
// Prefix: "With", code editors will help you navigate through all // Prefix: "With", code editors will help you navigate through all
// configuration options without even a glitch to the documentation. // configuration options without even a glitch to the documentation.
app.Run(iris.Addr(":8080"), iris.WithoutStartupLog, iris.WithCharset("UTF-8")) app.Listen(":8080", iris.WithoutStartupLog, iris.WithCharset("UTF-8"))
// or before run: // or before run:
// app.Configure(iris.WithoutStartupLog, iris.WithCharset("UTF-8")) // app.Configure(iris.WithoutStartupLog, iris.WithCharset("UTF-8"))
// app.Run(iris.Addr(":8080")) // app.Listen(":8080")
} }
``` ```
@ -99,7 +99,7 @@ func main() {
// [...] // [...]
// Good when you have two configurations, one for development and a different one for production use. // Good when you have two configurations, one for development and a different one for production use.
app.Run(iris.Addr(":8080"), iris.WithConfiguration(iris.TOML("./configs/iris.tml"))) app.Listen(":8080", iris.WithConfiguration(iris.TOML("./configs/iris.tml")))
} }
``` ```
@ -129,7 +129,7 @@ func main() {
}) })
// [...] // [...]
app.Run(iris.Addr(":8080"), iris.WithConfiguration(iris.YAML("./configs/iris.yml"))) app.Listen(":8080", iris.WithConfiguration(iris.YAML("./configs/iris.yml")))
} }
``` ```
@ -141,7 +141,7 @@ func main() {
// from the main application's `Run` function. // from the main application's `Run` function.
// //
// Usage: // Usage:
// err := app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed)) // err := app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed))
// will return `nil` if the server's error was `http/iris#ErrServerClosed`. // will return `nil` if the server's error was `http/iris#ErrServerClosed`.
// //
// See `Configuration#IgnoreServerErrors []string` too. // See `Configuration#IgnoreServerErrors []string` too.
@ -278,6 +278,6 @@ func main() {
app := iris.New() app := iris.New()
app.Configure(counter.Configurator) app.Configure(counter.Configurator)
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
``` ```

View File

@ -12,7 +12,7 @@ func main() {
// [...] // [...]
// Good when you want to modify the whole configuration. // Good when you want to modify the whole configuration.
app.Run(iris.Addr(":8080"), iris.WithConfiguration(iris.Configuration{ // default configuration: app.Listen(":8080", iris.WithConfiguration(iris.Configuration{ // default configuration:
DisableStartupLog: false, DisableStartupLog: false,
DisableInterruptHandler: false, DisableInterruptHandler: false,
DisablePathCorrection: false, DisablePathCorrection: false,

View File

@ -13,9 +13,9 @@ func main() {
// [...] // [...]
// Good when you have two configurations, one for development and a different one for production use. // Good when you have two configurations, one for development and a different one for production use.
app.Run(iris.Addr(":8080"), iris.WithConfiguration(iris.TOML("./configs/iris.tml"))) app.Listen(":8080", iris.WithConfiguration(iris.TOML("./configs/iris.tml")))
// or before run: // or before run:
// app.Configure(iris.WithConfiguration(iris.TOML("./configs/iris.tml"))) // app.Configure(iris.WithConfiguration(iris.TOML("./configs/iris.tml")))
// app.Run(iris.Addr(":8080")) // app.Listen(":8080")
} }

View File

@ -14,9 +14,9 @@ func main() {
// Good when you have two configurations, one for development and a different one for production use. // Good when you have two configurations, one for development and a different one for production use.
// If iris.YAML's input string argument is "~" then it loads the configuration from the home directory // If iris.YAML's input string argument is "~" then it loads the configuration from the home directory
// and can be shared between many iris instances. // and can be shared between many iris instances.
app.Run(iris.Addr(":8080"), iris.WithConfiguration(iris.YAML("./configs/iris.yml"))) app.Listen(":8080", iris.WithConfiguration(iris.YAML("./configs/iris.yml")))
// or before run: // or before run:
// app.Configure(iris.WithConfiguration(iris.YAML("./configs/iris.yml"))) // app.Configure(iris.WithConfiguration(iris.YAML("./configs/iris.yml")))
// app.Run(iris.Addr(":8080")) // app.Listen(":8080")
} }

View File

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

View File

@ -15,9 +15,9 @@ func main() {
// Prefix: "With", code editors will help you navigate through all // Prefix: "With", code editors will help you navigate through all
// configuration options without even a glitch to the documentation. // configuration options without even a glitch to the documentation.
app.Run(iris.Addr(":8080"), iris.WithoutStartupLog, iris.WithCharset("UTF-8")) app.Listen(":8080", iris.WithoutStartupLog, iris.WithCharset("UTF-8"))
// or before run: // or before run:
// app.Configure(iris.WithoutStartupLog, iris.WithCharset("UTF-8")) // app.Configure(iris.WithoutStartupLog, iris.WithCharset("UTF-8"))
// app.Run(iris.Addr(":8080")) // app.Listen(":8080")
} }

View File

@ -26,7 +26,7 @@ func main() {
// http://localhost:8080 // http://localhost:8080
// http://localhost:8080/ok // http://localhost:8080/ok
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
func negronilikeTestMiddleware(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) { func negronilikeTestMiddleware(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {

View File

@ -23,7 +23,7 @@ func main() {
// http://localhost:8080 // http://localhost:8080
// http://localhost:8080/ok // http://localhost:8080/ok
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
func nativeTestMiddleware(w http.ResponseWriter, r *http.Request) { func nativeTestMiddleware(w http.ResponseWriter, r *http.Request) {

View File

@ -41,5 +41,5 @@ func main() {
irisRouter(w, r) irisRouter(w, r)
}) })
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -53,5 +53,5 @@ func main() {
ctx.Writef("Hi") ctx.Writef("Hi")
}) })
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -60,5 +60,5 @@ func main() {
// GET: http://localhost:8080/cookies/my_name/my_value // GET: http://localhost:8080/cookies/my_name/my_value
// GET: http://localhost:8080/cookies/my_name // GET: http://localhost:8080/cookies/my_name
// DELETE: http://localhost:8080/cookies/my_name // DELETE: http://localhost:8080/cookies/my_name
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -55,5 +55,5 @@ func newApp() *iris.Application {
func main() { func main() {
app := newApp() app := newApp()
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -23,7 +23,7 @@ func runServer() {
app.Get("/", func(ctx iris.Context) { app.Get("/", func(ctx iris.Context) {
ctx.HTML("<h1> Hello Desktop</h1>") ctx.HTML("<h1> Hello Desktop</h1>")
}) })
app.Run(iris.Addr(addr)) app.Listen(addr)
} }
func showAndWaitWindow() { func showAndWaitWindow() {

View File

@ -21,7 +21,7 @@ func runServer() {
app.Get("/", func(ctx iris.Context) { app.Get("/", func(ctx iris.Context) {
ctx.HTML("<head><title>My App</title></head><body><h1>Hello Desktop</h1></body>") ctx.HTML("<head><title>My App</title></head><body><h1>Hello Desktop</h1></body>")
}) })
app.Run(iris.Addr(addr)) app.Listen(addr)
} }
func showAndWaitWindow() { func showAndWaitWindow() {

View File

@ -30,7 +30,7 @@ func runServer() {
app.Get("/", func(ctx iris.Context) { app.Get("/", func(ctx iris.Context) {
ctx.HTML("<h1> Hello Desktop</h1>") ctx.HTML("<h1> Hello Desktop</h1>")
}) })
app.Run(iris.Addr(addr)) app.Listen(addr)
} }
func showAndWaitWindow() { func showAndWaitWindow() {

View File

@ -22,5 +22,5 @@ func main() {
ctx.Writef("id: %d", ctx.Params().GetUintDefault("id", 0)) ctx.Writef("id: %d", ctx.Params().GetUintDefault("id", 0))
}) })
app.Run(iris.Addr(*addr)) app.Listen(*addr)
} }

View File

@ -35,7 +35,7 @@ func newApp() *iris.Application {
func main() { func main() {
app := newApp() app := newApp()
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
func hi(ctx iris.Context) { func hi(ctx iris.Context) {

View File

@ -35,7 +35,7 @@ func newApp() *iris.Application {
func main() { func main() {
app := newApp() app := newApp()
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
func hi(ctx iris.Context) { func hi(ctx iris.Context) {

View File

@ -46,5 +46,5 @@ func main() {
// http://localhost:8080 // http://localhost:8080
// should give: NoCredentialProviders // should give: NoCredentialProviders
// which is correct, you have to authorize your aws, we asumme that you know how to. // which is correct, you have to authorize your aws, we asumme that you know how to.
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -34,5 +34,5 @@ func main() {
// Start and navigate to http://localhost:8080 // Start and navigate to http://localhost:8080
// and go to the previous terminal of your running cors/simple/main.go server // and go to the previous terminal of your running cors/simple/main.go server
// and see the logs. // and see the logs.
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

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

View File

@ -35,7 +35,7 @@ func main() {
// GET: http://localhost:8080/user/signup // GET: http://localhost:8080/user/signup
// POST: http://localhost:8080/user/signup // POST: http://localhost:8080/user/signup
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
func getSignupForm(ctx iris.Context) { func getSignupForm(ctx iris.Context) {

View File

@ -52,5 +52,5 @@ func main() {
app.Get("/", getTokenHandler) app.Get("/", getTokenHandler)
app.Get("/secured", j.Serve, myAuthenticatedHandler) app.Get("/secured", j.Serve, myAuthenticatedHandler)
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -20,5 +20,5 @@ func main() {
ctx.Writef("success!\n") ctx.Writef("success!\n")
}) })
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -35,5 +35,5 @@ func main() {
// http://localhost:8080/ // http://localhost:8080/
// http://localhost:8080/anotfound // http://localhost:8080/anotfound
// http://localhost:8080/metrics // http://localhost:8080/metrics
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -34,5 +34,5 @@ func main() {
ctx.Writef("Hello from /home") ctx.Writef("Hello from /home")
}) })
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -25,7 +25,7 @@ func main() {
ctx.HTML("<b>Hello, world!</b>") ctx.HTML("<b>Hello, world!</b>")
}) })
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
// Read more at: https://github.com/didip/tollbooth // Read more at: https://github.com/didip/tollbooth

View File

@ -48,5 +48,5 @@ func newApp() *iris.Application {
func main() { func main() {
app := newApp() app := newApp()
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -32,5 +32,5 @@ func main() {
// http://localhost:8080/static/css/bootstrap.min.css // http://localhost:8080/static/css/bootstrap.min.css
// http://localhost:8080/static/js/jquery-2.1.1.js // http://localhost:8080/static/js/jquery-2.1.1.js
// http://localhost:8080/static/favicon.ico // http://localhost:8080/static/favicon.ico
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -32,5 +32,5 @@ func main() {
// http://localhost:8080/static/css/bootstrap.min.css // http://localhost:8080/static/css/bootstrap.min.css
// http://localhost:8080/static/js/jquery-2.1.1.js // http://localhost:8080/static/js/jquery-2.1.1.js
// http://localhost:8080/static/favicon.ico // http://localhost:8080/static/favicon.ico
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -20,5 +20,5 @@ func main() {
so iris serves your favicon in that path too (you can change it).`) so iris serves your favicon in that path too (you can change it).`)
}) // if favicon doesn't show to you, try to clear your browser's cache. }) // if favicon doesn't show to you, try to clear your browser's cache.
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -12,5 +12,5 @@ func main() {
ctx.SendFile(file, "c.zip") ctx.SendFile(file, "c.zip")
}) })
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -32,5 +32,5 @@ func main() {
// http://localhost:8080/index.html // http://localhost:8080/index.html
// http://localhost:8080/app.js // http://localhost:8080/app.js
// http://localhost:8080/css/main.css // http://localhost:8080/css/main.css
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -61,5 +61,5 @@ func main() {
// http://localhost:8080/.well-known/metrics // http://localhost:8080/.well-known/metrics
// //
// Remember: we could use the root wildcard `app.Get("/{param:path}")` and serve the files manually as well. // Remember: we could use the root wildcard `app.Get("/{param:path}")` and serve the files manually as well.
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -37,5 +37,5 @@ func main() {
// http://localhost:8080/app.js // http://localhost:8080/app.js
// http://localhost:8080/css/main.css // http://localhost:8080/css/main.css
// http://localhost:8080/app2 // http://localhost:8080/app2
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -25,5 +25,5 @@ func newApp() *iris.Application {
func main() { func main() {
app := newApp() app := newApp()
app.Run(iris.Addr(addr)) app.Listen(addr)
} }

View File

@ -38,5 +38,5 @@ func main() {
// http://localhost:8080 // http://localhost:8080
// http://localhost:8080/ping // http://localhost:8080/ping
// http://localhost:8080/hello // http://localhost:8080/hello
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed)) app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed))
} }

View File

@ -33,7 +33,7 @@ func main() {
// http://localhost:8080/your_name // http://localhost:8080/your_name
// http://localhost:8080/service/your_name // http://localhost:8080/service/your_name
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
func hello(to string) string { func hello(to string) string {

View File

@ -42,7 +42,7 @@ func main() {
// http://localhost:8080/users // http://localhost:8080/users
// http://localhost:8080/users/William%20Woe // http://localhost:8080/users/William%20Woe
// http://localhost:8080/users/William%20Woe/age // http://localhost:8080/users/William%20Woe/age
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
/* /*

View File

@ -11,7 +11,7 @@ we use the `iris.Addr` which is an `iris.Runner` type
```go ```go
// Listening on tcp with network address 0.0.0.0:8080 // Listening on tcp with network address 0.0.0.0:8080
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 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
@ -166,7 +166,7 @@ app.ConfigureHost(func(h *iris.Supervisor) {
println("server terminated") println("server terminated")
}) })
}) })
app.Run(iris.Addr(":8080")) app.Listen(":8080")
``` ```
Access to all hosts that serve your application can be provided by Access to all hosts that serve your application can be provided by
@ -201,7 +201,7 @@ app := iris.New()
app.Get("/", indexHandler) app.Get("/", indexHandler)
// run in different goroutine in order to not block the main "goroutine". // 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, // 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. // without "go" keyword because we want to block at the last server-run.
app.NewHost(&http.Server{Addr:":9090"}).ListenAndServe() app.NewHost(&http.Server{Addr:":9090"}).ListenAndServe()
@ -246,6 +246,6 @@ func main() {
ctx.HTML(" <h1>hi, I just exist in order to see if the server is closed</h1>") ctx.HTML(" <h1>hi, I just exist in order to see if the server is closed</h1>")
}) })
app.Run(iris.Addr(":8080"), iris.WithoutInterruptHandler) app.Listen(":8080", iris.WithoutInterruptHandler)
} }
``` ```

View File

@ -22,7 +22,7 @@ func main() {
// http://localhost:8080/ // http://localhost:8080/
// http://localhost:8080/mypath // http://localhost:8080/mypath
app.Run(iris.Server(srv)) // same as app.Run(iris.Addr(":8080")) app.Run(iris.Server(srv)) // same as app.Listen(":8080")
// More: // More:
// see "multi" if you need to use more than one server at the same app. // see "multi" if you need to use more than one server at the same app.

View File

@ -43,5 +43,5 @@ func main() {
// you can just make a new http.Server instead. // you can just make a new http.Server instead.
// http://localhost:8080/ // http://localhost:8080/
// http://localhost:8080/mypath // http://localhost:8080/mypath
app.Run(iris.Addr(":8080")) // Block here. app.Listen(":8080") // Block here.
} }

View File

@ -25,7 +25,7 @@ func main() {
// http://localhost:8080/ // http://localhost:8080/
// http://localhost:8080/mypath // http://localhost:8080/mypath
println("Start a server listening on http://localhost:8080") println("Start a server listening on http://localhost:8080")
srv.ListenAndServe() // same as app.Run(iris.Addr(":8080")) srv.ListenAndServe() // same as app.Listen(":8080")
// Notes: // Notes:
// Banner is not shown at all. Same for the Interrupt Handler, even if app's configuration allows them. // Banner is not shown at all. Same for the Interrupt Handler, even if app's configuration allows them.

View File

@ -42,5 +42,5 @@ func main() {
// Start the server and disable the default interrupt handler in order to // Start the server and disable the default interrupt handler in order to
// handle it clear and simple by our own, without any issues. // handle it clear and simple by our own, without any issues.
app.Run(iris.Addr(":8080"), iris.WithoutInterruptHandler) app.Listen(":8080", iris.WithoutInterruptHandler)
} }

View File

@ -30,5 +30,5 @@ func main() {
}) })
// http://localhost:8080 // http://localhost:8080
app.Run(iris.Addr(":8080"), iris.WithoutInterruptHandler) app.Listen(":8080", iris.WithoutInterruptHandler)
} }

View File

@ -20,7 +20,7 @@ func main() {
ctx.HTML("<h1>Hello</h1>\n") ctx.HTML("<h1>Hello</h1>\n")
}) })
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed)) app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed))
/* There are more easy ways to notify for global shutdown using the `iris.RegisterOnInterrupt` for default signal interrupt events. /* There are more easy ways to notify for global shutdown using the `iris.RegisterOnInterrupt` for default signal interrupt events.
You can even go it even further by looking at the: "graceful-shutdown" example. You can even go it even further by looking at the: "graceful-shutdown" example.

View File

@ -14,10 +14,10 @@ func main() {
ctx.Application().ConfigurationReadOnly().GetVHost()) ctx.Application().ConfigurationReadOnly().GetVHost())
}) })
app.Run(iris.Addr(":8080"), iris.WithTunneling) app.Listen(":8080", iris.WithTunneling)
/* The full configuration can be set as: /* The full configuration can be set as:
app.Run(iris.Addr(":8080"), iris.WithConfiguration( app.Listen(":8080", iris.WithConfiguration(
iris.Configuration{ iris.Configuration{
Tunneling: iris.TunnelingConfiguration{ Tunneling: iris.TunnelingConfiguration{
AuthToken: "my-ngrok-auth-client-token", AuthToken: "my-ngrok-auth-client-token",

View File

@ -12,5 +12,6 @@ func main() {
}) })
// http://localhost:8080 // http://localhost:8080
app.Run(iris.Addr(":8080")) // Identical to: app.Run(iris.Addr(":8080"))
app.Listen(":8080")
} }

View File

@ -11,12 +11,12 @@ func main() {
ctx.HTML("<h1>Hello World!</h1>") ctx.HTML("<h1>Hello World!</h1>")
}) })
err := app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed)) err := app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed))
if err != nil { if err != nil {
// do something // do something
} }
// same as: // same as:
// err := app.Run(iris.Addr(":8080")) // err := app.Listen(":8080")
// if err != nil && (err != iris.ErrServerClosed || err.Error() != iris.ErrServerClosed.Error()) { // if err != nil && (err != iris.ErrServerClosed || err.Error() != iris.ErrServerClosed.Error()) {
// [...] // [...]
// } // }

View File

@ -34,7 +34,7 @@ func TestListenAddr(t *testing.T) {
app.Shutdown(ctx) app.Shutdown(ctx)
}() }()
err := app.Run(iris.Addr(":9829")) err := app.Listen(":9829")
// in this case the error should be logged and return as well. // in this case the error should be logged and return as well.
if err != iris.ErrServerClosed { if err != iris.ErrServerClosed {
t.Fatalf("expecting err to be `iris.ErrServerClosed` but got: %v", err) t.Fatalf("expecting err to be `iris.ErrServerClosed` but got: %v", err)
@ -63,7 +63,7 @@ func TestListenAddrWithoutServerErr(t *testing.T) {
// we disable the ErrServerClosed, so the error should be nil when server is closed by `app.Shutdown`. // we disable the ErrServerClosed, so the error should be nil when server is closed by `app.Shutdown`.
// so in this case the iris/http.ErrServerClosed should be NOT logged and NOT return. // so in this case the iris/http.ErrServerClosed should be NOT logged and NOT return.
err := app.Run(iris.Addr(":9827"), iris.WithoutServerError(iris.ErrServerClosed)) err := app.Listen(":9827", iris.WithoutServerError(iris.ErrServerClosed))
if err != nil { if err != nil {
t.Fatalf("expecting err to be nil but got: %v", err) t.Fatalf("expecting err to be nil but got: %v", err)
} }

View File

@ -24,5 +24,5 @@ func main() {
// http://localhost:8080?referer=https://twitter.com/Xinterio/status/1023566830974251008 // http://localhost:8080?referer=https://twitter.com/Xinterio/status/1023566830974251008
// http://localhost:8080?referer=https://www.google.com/search?q=Top+6+golang+web+frameworks&oq=Top+6+golang+web+frameworks // http://localhost:8080?referer=https://www.google.com/search?q=Top+6+golang+web+frameworks&oq=Top+6+golang+web+frameworks
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed)) app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed))
} }

View File

@ -19,7 +19,7 @@ func main() {
// //
// The response should be: // The response should be:
// Received: main.config{Addr:"localhost:8080", ServerName:"Iris"} // Received: main.config{Addr:"localhost:8080", ServerName:"Iris"}
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed), iris.WithOptimizations) app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed), iris.WithOptimizations)
} }
func newApp() *iris.Application { func newApp() *iris.Application {

View File

@ -19,7 +19,7 @@ func main() {
// //
// The response should be: // The response should be:
// Received: main.config{Addr:"localhost:8080", ServerName:"Iris"} // Received: main.config{Addr:"localhost:8080", ServerName:"Iris"}
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed), iris.WithOptimizations) app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed), iris.WithOptimizations)
} }
func newApp() *iris.Application { func newApp() *iris.Application {

View File

@ -40,5 +40,5 @@ func main() {
ctx.Writef("Username: %s", username) ctx.Writef("Username: %s", username)
}) })
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -118,7 +118,7 @@ func main() {
// This request will fail due to the empty `User.FirstName` (fname in json) // This request will fail due to the empty `User.FirstName` (fname in json)
// and `User.LastName` (lname in json). // and `User.LastName` (lname in json).
// Check your iris' application terminal output. // Check your iris' application terminal output.
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed)) app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed))
} }
// UserStructLevelValidation contains custom struct level validations that don't always // UserStructLevelValidation contains custom struct level validations that don't always

View File

@ -60,5 +60,5 @@ func main() {
// //
// The response should be: // The response should be:
// Received: main.Company{Name:"iris-Go", City:"New York", Other:"Something here"} // Received: main.Company{Name:"iris-Go", City:"New York", Other:"Something here"}
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed), iris.WithOptimizations) app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed), iris.WithOptimizations)
} }

View File

@ -30,7 +30,7 @@ Check the terminal window for any queries logs.`)
// and ctx.GetBody methods the default golang and net/http behavior // and ctx.GetBody methods the default golang and net/http behavior
// is to consume the readen data - they are not available on any next handlers in the chain - // is to consume the readen data - they are not available on any next handlers in the chain -
// to change that behavior just pass the `WithoutBodyConsumptionOnUnmarshal` option. // to change that behavior just pass the `WithoutBodyConsumptionOnUnmarshal` option.
app.Run(iris.Addr(":8080"), iris.WithoutBodyConsumptionOnUnmarshal) app.Listen(":8080", iris.WithoutBodyConsumptionOnUnmarshal)
} }
func logAllBody(ctx iris.Context) { func logAllBody(ctx iris.Context) {

View File

@ -25,5 +25,5 @@ func main() {
}) })
// http://localhost:8080?name=iris&age=3 // http://localhost:8080?name=iris&age=3
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -20,7 +20,7 @@ func main() {
// //
// The response should be: // The response should be:
// Received: main.person{XMLName:xml.Name{Space:"", Local:"person"}, Name:"Winston Churchill", Age:90, Description:"Description of this person, the body of this inner element."} // Received: main.person{XMLName:xml.Name{Space:"", Local:"person"}, Name:"Winston Churchill", Age:90, Description:"Description of this person, the body of this inner element."}
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed), iris.WithOptimizations) app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed), iris.WithOptimizations)
} }
func newApp() *iris.Application { func newApp() *iris.Application {

View File

@ -32,5 +32,5 @@ func handler(ctx iris.Context) {
func main() { func main() {
app := newApp() app := newApp()
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -61,5 +61,5 @@ func main() {
// http://localhost:8080/2 // http://localhost:8080/2
// http://lcoalhost:8080/notfoundhere // http://lcoalhost:8080/notfoundhere
// see the output on the console. // see the output on the console.
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed)) app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed))
} }

View File

@ -82,7 +82,7 @@ func main() {
// http://localhost:8080/1 // http://localhost:8080/1
// http://localhost:8080/2 // http://localhost:8080/2
// http://lcoalhost:8080/notfoundhere // http://lcoalhost:8080/notfoundhere
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed)) app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed))
} }
var excludeExtensions = [...]string{ var excludeExtensions = [...]string{

View File

@ -35,7 +35,7 @@ func main() {
// http://localhost:8080/1 // http://localhost:8080/1
// http://localhost:8080/2 // http://localhost:8080/2
// http://lcoalhost:8080/notfoundhere // http://lcoalhost:8080/notfoundhere
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed)) app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed))
} }
// get a filename based on the date, file logs works that way the most times // get a filename based on the date, file logs works that way the most times

View File

@ -124,5 +124,5 @@ func main() {
}) })
// start the server at http://localhost:8080 with post limit at 5 MB. // start the server at http://localhost:8080 with post limit at 5 MB.
app.Run(iris.Addr(":8080") /* 0.*/, iris.WithPostMaxMemory(maxSize)) app.Listen(":8080" /* 0.*/, iris.WithPostMaxMemory(maxSize))
} }

View File

@ -72,7 +72,7 @@ func main() {
}) })
// start the server at http://localhost:8080 with post limit at 32 MB. // start the server at http://localhost:8080 with post limit at 32 MB.
app.Run(iris.Addr(":8080"), iris.WithPostMaxMemory(32<<20)) app.Listen(":8080", iris.WithPostMaxMemory(32<<20))
} }
func saveUploadedFile(fh *multipart.FileHeader, destDirectory string) (int64, error) { func saveUploadedFile(fh *multipart.FileHeader, destDirectory string) (int64, error) {

View File

@ -110,5 +110,5 @@ func newApp() *iris.Application {
func main() { func main() {
app := newApp() app := newApp()
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -50,5 +50,5 @@ func main() {
} }
}) })
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -18,5 +18,5 @@ func main() {
app := newApp() app := newApp()
// http://localhost:8080 // http://localhost:8080
// http://localhost:8080/yourname // http://localhost:8080/yourname
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed)) app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed))
} }

View File

@ -44,7 +44,7 @@ func main() {
}) })
}() // ... }() // ...
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed)) app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed))
} }
/* For a golang SSE client you can look at: https://github.com/r3labs/sse#example-client */ /* For a golang SSE client you can look at: https://github.com/r3labs/sse#example-client */

View File

@ -187,5 +187,5 @@ func main() {
// http://localhost:8080 // http://localhost:8080
// http://localhost:8080/events // http://localhost:8080/events
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed)) app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed))
} }

View File

@ -50,5 +50,5 @@ func main() {
} }
}) })
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -50,5 +50,5 @@ func main() {
"not been shown. But it has a transient scope(default) so, it is visible as expected!</h1>") "not been shown. But it has a transient scope(default) so, it is visible as expected!</h1>")
}) })
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -17,5 +17,5 @@ func main() {
ctx.GzipResponseWriter().WriteString("Hello World!") ctx.GzipResponseWriter().WriteString("Hello World!")
}) })
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -91,5 +91,5 @@ func main() {
// //
// `iris.WithoutServerError` is an optional configurator, // `iris.WithoutServerError` is an optional configurator,
// if passed to the `Run` then it will not print its passed error as an actual server error. // if passed to the `Run` then it will not print its passed error as an actual server error.
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed), iris.WithOptimizations) app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed), iris.WithOptimizations)
} }

View File

@ -85,5 +85,5 @@ func main() {
// or http://localhost:8080/other?lang=en-US // or http://localhost:8080/other?lang=en-US
// //
// or use cookies to set the language. // 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"))
} }

View File

@ -42,7 +42,7 @@ func main() {
// Navigate to http://localhost:8080/ping // Navigate to http://localhost:8080/ping
// and open the ./logs{TODAY}.txt file. // and open the ./logs{TODAY}.txt file.
if err := app.Run(iris.Addr(":8080"), iris.WithoutBanner, iris.WithoutServerError(iris.ErrServerClosed)); err != nil { if err := app.Listen(":8080", iris.WithoutBanner, iris.WithoutServerError(iris.ErrServerClosed)); err != nil {
app.Logger().Warn("Shutdown with error: " + err.Error()) app.Logger().Warn("Shutdown with error: " + err.Error())
} }
} }

View File

@ -17,5 +17,5 @@ func main() {
app.Any("/debug/pprof", p) app.Any("/debug/pprof", p)
app.Any("/debug/pprof/{action:path}", p) app.Any("/debug/pprof/{action:path}", p)
// ___________ // ___________
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -24,7 +24,7 @@ func main() {
// pass the middleware before the main handler or use the `recaptcha.SiteVerify`. // pass the middleware before the main handler or use the `recaptcha.SiteVerify`.
app.Post("/comment", r, postComment) app.Post("/comment", r, postComment)
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
var htmlForm = `<form action="/comment" method="POST"> var htmlForm = `<form action="/comment" method="POST">

View File

@ -36,5 +36,5 @@ func main() {
ctx.Writef("succeed.") ctx.Writef("succeed.")
}) })
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }

View File

@ -21,7 +21,7 @@ func main() {
}) })
// http://localhost:8080, refresh it 5-6 times. // http://localhost:8080, refresh it 5-6 times.
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
// Note: // Note:

View File

@ -16,7 +16,7 @@ func main() {
app.Logger().SetLevel("debug") app.Logger().SetLevel("debug")
mvc.Configure(app.Party("/basic"), basicMVC) mvc.Configure(app.Party("/basic"), basicMVC)
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
func basicMVC(app *mvc.Application) { func basicMVC(app *mvc.Application) {

View File

@ -23,7 +23,7 @@ func main() {
mvcApp.Handle(new(myController)) mvcApp.Handle(new(myController))
// http://localhost:8080 // http://localhost:8080
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
type myController struct { type myController struct {

View File

@ -50,7 +50,7 @@ func main() {
// http://localhost:8080/ping // http://localhost:8080/ping
// http://localhost:8080/hello // http://localhost:8080/hello
// http://localhost:8080/custom_path // http://localhost:8080/custom_path
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
// ExampleController serves the "/", "/ping" and "/hello". // ExampleController serves the "/", "/ping" and "/hello".

View File

@ -20,7 +20,7 @@ func main() {
// http://localhost:8080/other // http://localhost:8080/other
// //
// refresh every 10 seconds and you'll see different time output. // refresh every 10 seconds and you'll see different time output.
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
func configure(m *mvc.Application) { func configure(m *mvc.Application) {

View File

@ -84,7 +84,7 @@ func main() {
m := mvc.New(app) m := mvc.New(app)
m.Handle(&exampleController{}) m.Handle(&exampleController{})
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
type exampleController struct{} type exampleController struct{}

View File

@ -51,7 +51,7 @@ func main() {
m.Handle(&exampleController{}) m.Handle(&exampleController{})
app.Run(iris.Addr(":8080")) app.Listen(":8080")
} }
func doneHandler(ctx iris.Context) { func doneHandler(ctx iris.Context) {

Some files were not shown because too many files have changed in this diff Show More