mirror of
https://github.com/kataras/iris.git
synced 2025-03-14 02:56:26 +01:00
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:
parent
b6445c7238
commit
0d26f24eb7
|
@ -33,7 +33,7 @@ func main() {
|
|||
})
|
||||
})
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ func main() {
|
|||
})
|
||||
})
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ func main() {
|
|||
})
|
||||
})
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ func main() {
|
|||
})
|
||||
})
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ func main() {
|
|||
})
|
||||
})
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ func main() {
|
|||
})
|
||||
})
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
```
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ func main() {
|
|||
|
||||
mvc.New(app).Handle(new(controllers.HomeController))
|
||||
|
||||
app.Run(iris.Addr(":5000"))
|
||||
app.Listen(":5000")
|
||||
}
|
||||
|
||||
type err struct {
|
||||
|
|
|
@ -24,7 +24,7 @@ func main() {
|
|||
app.Delete("/del", delHandler)
|
||||
*/
|
||||
|
||||
app.Run(iris.Addr(":5000"))
|
||||
app.Listen(":5000")
|
||||
}
|
||||
|
||||
// Set and Get
|
||||
|
|
|
@ -153,7 +153,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) {
|
||||
|
|
|
@ -51,5 +51,5 @@ func main() {
|
|||
//
|
||||
// Example usage:
|
||||
// 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")
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ func newApp() *iris.Application {
|
|||
func main() {
|
||||
app := newApp()
|
||||
// open http://localhost:8080/admin
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
||||
func h(ctx iris.Context) {
|
||||
|
|
|
@ -400,7 +400,7 @@ func main() {
|
|||
})
|
||||
|
||||
// http://localhost:3000
|
||||
app.Run(iris.Addr("localhost:3000"))
|
||||
app.Listen("localhost:3000")
|
||||
}
|
||||
|
||||
type ProviderIndex struct {
|
||||
|
|
2
_examples/cache/client-side/main.go
vendored
2
_examples/cache/client-side/main.go
vendored
|
@ -30,7 +30,7 @@ func main() {
|
|||
// })
|
||||
|
||||
app.Get("/", greet)
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
||||
func greet(ctx iris.Context) {
|
||||
|
|
2
_examples/cache/simple/main.go
vendored
2
_examples/cache/simple/main.go
vendored
|
@ -63,7 +63,7 @@ func main() {
|
|||
// 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.
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
||||
func writeMarkdown(ctx iris.Context) {
|
||||
|
|
|
@ -26,7 +26,7 @@ func main() {
|
|||
// [...]
|
||||
|
||||
// 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,
|
||||
DisableInterruptHandler: false,
|
||||
DisablePathCorrection: false,
|
||||
|
@ -60,11 +60,11 @@ func main() {
|
|||
// Prefix: "With", code editors will help you navigate through all
|
||||
// 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:
|
||||
// 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.
|
||||
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.
|
||||
//
|
||||
// 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`.
|
||||
//
|
||||
// See `Configuration#IgnoreServerErrors []string` too.
|
||||
|
@ -278,6 +278,6 @@ func main() {
|
|||
app := iris.New()
|
||||
app.Configure(counter.Configurator)
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
```
|
|
@ -12,7 +12,7 @@ func main() {
|
|||
// [...]
|
||||
|
||||
// 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,
|
||||
DisableInterruptHandler: false,
|
||||
DisablePathCorrection: false,
|
||||
|
|
|
@ -13,9 +13,9 @@ func main() {
|
|||
// [...]
|
||||
|
||||
// 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:
|
||||
// app.Configure(iris.WithConfiguration(iris.TOML("./configs/iris.tml")))
|
||||
// app.Run(iris.Addr(":8080"))
|
||||
// app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -14,9 +14,9 @@ func main() {
|
|||
// 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
|
||||
// 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:
|
||||
// app.Configure(iris.WithConfiguration(iris.YAML("./configs/iris.yml")))
|
||||
// app.Run(iris.Addr(":8080"))
|
||||
// app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ func main() {
|
|||
// Good when you share configuration between multiple iris instances.
|
||||
// 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.
|
||||
app.Run(iris.Addr(":8080"), iris.WithGlobalConfiguration)
|
||||
app.Listen(":8080", iris.WithGlobalConfiguration)
|
||||
// or before run:
|
||||
// app.Configure(iris.WithGlobalConfiguration)
|
||||
// app.Run(iris.Addr(":8080"))
|
||||
// app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -15,9 +15,9 @@ func main() {
|
|||
// Prefix: "With", code editors will help you navigate through all
|
||||
// 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:
|
||||
// app.Configure(iris.WithoutStartupLog, iris.WithCharset("UTF-8"))
|
||||
// app.Run(iris.Addr(":8080"))
|
||||
// app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func main() {
|
|||
|
||||
// http://localhost:8080
|
||||
// http://localhost:8080/ok
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
||||
func negronilikeTestMiddleware(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
|
||||
|
|
|
@ -23,7 +23,7 @@ func main() {
|
|||
|
||||
// http://localhost:8080
|
||||
// http://localhost:8080/ok
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
||||
func nativeTestMiddleware(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
@ -41,5 +41,5 @@ func main() {
|
|||
irisRouter(w, r)
|
||||
})
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -53,5 +53,5 @@ func main() {
|
|||
ctx.Writef("Hi")
|
||||
})
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -60,5 +60,5 @@ func main() {
|
|||
// GET: http://localhost:8080/cookies/my_name/my_value
|
||||
// GET: http://localhost:8080/cookies/my_name
|
||||
// DELETE: http://localhost:8080/cookies/my_name
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -55,5 +55,5 @@ func newApp() *iris.Application {
|
|||
|
||||
func main() {
|
||||
app := newApp()
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ func runServer() {
|
|||
app.Get("/", func(ctx iris.Context) {
|
||||
ctx.HTML("<h1> Hello Desktop</h1>")
|
||||
})
|
||||
app.Run(iris.Addr(addr))
|
||||
app.Listen(addr)
|
||||
}
|
||||
|
||||
func showAndWaitWindow() {
|
||||
|
|
|
@ -21,7 +21,7 @@ func runServer() {
|
|||
app.Get("/", func(ctx iris.Context) {
|
||||
ctx.HTML("<head><title>My App</title></head><body><h1>Hello Desktop</h1></body>")
|
||||
})
|
||||
app.Run(iris.Addr(addr))
|
||||
app.Listen(addr)
|
||||
}
|
||||
|
||||
func showAndWaitWindow() {
|
||||
|
|
|
@ -30,7 +30,7 @@ func runServer() {
|
|||
app.Get("/", func(ctx iris.Context) {
|
||||
ctx.HTML("<h1> Hello Desktop</h1>")
|
||||
})
|
||||
app.Run(iris.Addr(addr))
|
||||
app.Listen(addr)
|
||||
}
|
||||
|
||||
func showAndWaitWindow() {
|
||||
|
|
|
@ -22,5 +22,5 @@ func main() {
|
|||
ctx.Writef("id: %d", ctx.Params().GetUintDefault("id", 0))
|
||||
})
|
||||
|
||||
app.Run(iris.Addr(*addr))
|
||||
app.Listen(*addr)
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ func newApp() *iris.Application {
|
|||
|
||||
func main() {
|
||||
app := newApp()
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
||||
func hi(ctx iris.Context) {
|
||||
|
|
|
@ -35,7 +35,7 @@ func newApp() *iris.Application {
|
|||
|
||||
func main() {
|
||||
app := newApp()
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
||||
func hi(ctx iris.Context) {
|
||||
|
|
|
@ -46,5 +46,5 @@ func main() {
|
|||
// http://localhost:8080
|
||||
// should give: NoCredentialProviders
|
||||
// which is correct, you have to authorize your aws, we asumme that you know how to.
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -34,5 +34,5 @@ func main() {
|
|||
// Start and navigate to http://localhost:8080
|
||||
// and go to the previous terminal of your running cors/simple/main.go server
|
||||
// and see the logs.
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -46,9 +46,8 @@ func main() {
|
|||
|
||||
// iris.WithoutPathCorrectionRedirection | iris#Configuration.DisablePathCorrectionRedirection:
|
||||
// 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)`
|
||||
// on the server side if you wish
|
||||
// Add the iris.WithoutPathCorrectionRedirection option
|
||||
// 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.
|
||||
app.Run(iris.Addr(":80"), iris.WithoutPathCorrectionRedirection)
|
||||
app.Listen(":80", iris.WithoutPathCorrectionRedirection)
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ func main() {
|
|||
|
||||
// GET: http://localhost:8080/user/signup
|
||||
// POST: http://localhost:8080/user/signup
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
||||
func getSignupForm(ctx iris.Context) {
|
||||
|
|
|
@ -52,5 +52,5 @@ func main() {
|
|||
|
||||
app.Get("/", getTokenHandler)
|
||||
app.Get("/secured", j.Serve, myAuthenticatedHandler)
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -20,5 +20,5 @@ func main() {
|
|||
ctx.Writef("success!\n")
|
||||
})
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -35,5 +35,5 @@ func main() {
|
|||
// http://localhost:8080/
|
||||
// http://localhost:8080/anotfound
|
||||
// http://localhost:8080/metrics
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -34,5 +34,5 @@ func main() {
|
|||
ctx.Writef("Hello from /home")
|
||||
})
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ func main() {
|
|||
ctx.HTML("<b>Hello, world!</b>")
|
||||
})
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
||||
// Read more at: https://github.com/didip/tollbooth
|
||||
|
|
|
@ -48,5 +48,5 @@ func newApp() *iris.Application {
|
|||
|
||||
func main() {
|
||||
app := newApp()
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -32,5 +32,5 @@ func main() {
|
|||
// http://localhost:8080/static/css/bootstrap.min.css
|
||||
// http://localhost:8080/static/js/jquery-2.1.1.js
|
||||
// http://localhost:8080/static/favicon.ico
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -32,5 +32,5 @@ func main() {
|
|||
// http://localhost:8080/static/css/bootstrap.min.css
|
||||
// http://localhost:8080/static/js/jquery-2.1.1.js
|
||||
// http://localhost:8080/static/favicon.ico
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -20,5 +20,5 @@ func main() {
|
|||
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.
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -12,5 +12,5 @@ func main() {
|
|||
ctx.SendFile(file, "c.zip")
|
||||
})
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -32,5 +32,5 @@ func main() {
|
|||
// http://localhost:8080/index.html
|
||||
// http://localhost:8080/app.js
|
||||
// http://localhost:8080/css/main.css
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -61,5 +61,5 @@ func main() {
|
|||
// http://localhost:8080/.well-known/metrics
|
||||
//
|
||||
// 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")
|
||||
}
|
||||
|
|
|
@ -37,5 +37,5 @@ func main() {
|
|||
// http://localhost:8080/app.js
|
||||
// http://localhost:8080/css/main.css
|
||||
// http://localhost:8080/app2
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -25,5 +25,5 @@ func newApp() *iris.Application {
|
|||
|
||||
func main() {
|
||||
app := newApp()
|
||||
app.Run(iris.Addr(addr))
|
||||
app.Listen(addr)
|
||||
}
|
||||
|
|
|
@ -38,5 +38,5 @@ func main() {
|
|||
// http://localhost:8080
|
||||
// http://localhost:8080/ping
|
||||
// http://localhost:8080/hello
|
||||
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed))
|
||||
app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed))
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ func main() {
|
|||
|
||||
// http://localhost:8080/your_name
|
||||
// http://localhost:8080/service/your_name
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
||||
func hello(to string) string {
|
||||
|
|
|
@ -42,7 +42,7 @@ func main() {
|
|||
// http://localhost:8080/users
|
||||
// http://localhost:8080/users/William%20Woe
|
||||
// http://localhost:8080/users/William%20Woe/age
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -11,7 +11,7 @@ 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"))
|
||||
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
|
||||
|
@ -166,7 +166,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
|
||||
|
@ -201,7 +201,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()
|
||||
|
@ -246,6 +246,6 @@ func main() {
|
|||
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)
|
||||
}
|
||||
```
|
||||
|
|
|
@ -22,7 +22,7 @@ func main() {
|
|||
|
||||
// http://localhost:8080/
|
||||
// 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:
|
||||
// see "multi" if you need to use more than one server at the same app.
|
||||
|
|
|
@ -43,5 +43,5 @@ func main() {
|
|||
// you can just make a new http.Server instead.
|
||||
// http://localhost:8080/
|
||||
// http://localhost:8080/mypath
|
||||
app.Run(iris.Addr(":8080")) // Block here.
|
||||
app.Listen(":8080") // Block here.
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ func main() {
|
|||
// http://localhost:8080/
|
||||
// http://localhost:8080/mypath
|
||||
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:
|
||||
// Banner is not shown at all. Same for the Interrupt Handler, even if app's configuration allows them.
|
||||
|
|
|
@ -42,5 +42,5 @@ func main() {
|
|||
|
||||
// Start the server and disable the default interrupt handler in order to
|
||||
// handle it clear and simple by our own, without any issues.
|
||||
app.Run(iris.Addr(":8080"), iris.WithoutInterruptHandler)
|
||||
app.Listen(":8080", iris.WithoutInterruptHandler)
|
||||
}
|
||||
|
|
|
@ -30,5 +30,5 @@ func main() {
|
|||
})
|
||||
|
||||
// http://localhost:8080
|
||||
app.Run(iris.Addr(":8080"), iris.WithoutInterruptHandler)
|
||||
app.Listen(":8080", iris.WithoutInterruptHandler)
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ func main() {
|
|||
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.
|
||||
You can even go it even further by looking at the: "graceful-shutdown" example.
|
||||
|
|
|
@ -14,10 +14,10 @@ func main() {
|
|||
ctx.Application().ConfigurationReadOnly().GetVHost())
|
||||
})
|
||||
|
||||
app.Run(iris.Addr(":8080"), iris.WithTunneling)
|
||||
app.Listen(":8080", iris.WithTunneling)
|
||||
|
||||
/* The full configuration can be set as:
|
||||
app.Run(iris.Addr(":8080"), iris.WithConfiguration(
|
||||
app.Listen(":8080", iris.WithConfiguration(
|
||||
iris.Configuration{
|
||||
Tunneling: iris.TunnelingConfiguration{
|
||||
AuthToken: "my-ngrok-auth-client-token",
|
||||
|
|
|
@ -12,5 +12,6 @@ func main() {
|
|||
})
|
||||
|
||||
// http://localhost:8080
|
||||
app.Run(iris.Addr(":8080"))
|
||||
// Identical to: app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -11,12 +11,12 @@ func main() {
|
|||
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 {
|
||||
// do something
|
||||
}
|
||||
// same as:
|
||||
// err := app.Run(iris.Addr(":8080"))
|
||||
// err := app.Listen(":8080")
|
||||
// if err != nil && (err != iris.ErrServerClosed || err.Error() != iris.ErrServerClosed.Error()) {
|
||||
// [...]
|
||||
// }
|
||||
|
|
|
@ -34,7 +34,7 @@ func TestListenAddr(t *testing.T) {
|
|||
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.
|
||||
if err != iris.ErrServerClosed {
|
||||
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`.
|
||||
|
||||
// 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 {
|
||||
t.Fatalf("expecting err to be nil but got: %v", err)
|
||||
}
|
||||
|
|
|
@ -24,5 +24,5 @@ func main() {
|
|||
|
||||
// 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
|
||||
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed))
|
||||
app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed))
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ func main() {
|
|||
//
|
||||
// The response should be:
|
||||
// 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 {
|
||||
|
|
|
@ -19,7 +19,7 @@ func main() {
|
|||
//
|
||||
// The response should be:
|
||||
// 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 {
|
||||
|
|
|
@ -40,5 +40,5 @@ func main() {
|
|||
ctx.Writef("Username: %s", username)
|
||||
})
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ func main() {
|
|||
// This request will fail due to the empty `User.FirstName` (fname in json)
|
||||
// and `User.LastName` (lname in json).
|
||||
// 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
|
||||
|
|
|
@ -60,5 +60,5 @@ func main() {
|
|||
//
|
||||
// The response should be:
|
||||
// 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)
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ Check the terminal window for any queries logs.`)
|
|||
// 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 -
|
||||
// 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) {
|
||||
|
|
|
@ -25,5 +25,5 @@ func main() {
|
|||
})
|
||||
|
||||
// http://localhost:8080?name=iris&age=3
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ func main() {
|
|||
//
|
||||
// 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."}
|
||||
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed), iris.WithOptimizations)
|
||||
app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed), iris.WithOptimizations)
|
||||
}
|
||||
|
||||
func newApp() *iris.Application {
|
||||
|
|
|
@ -32,5 +32,5 @@ func handler(ctx iris.Context) {
|
|||
|
||||
func main() {
|
||||
app := newApp()
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -61,5 +61,5 @@ func main() {
|
|||
// http://localhost:8080/2
|
||||
// http://lcoalhost:8080/notfoundhere
|
||||
// see the output on the console.
|
||||
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed))
|
||||
app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed))
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ func main() {
|
|||
// http://localhost:8080/1
|
||||
// http://localhost:8080/2
|
||||
// http://lcoalhost:8080/notfoundhere
|
||||
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed))
|
||||
app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed))
|
||||
}
|
||||
|
||||
var excludeExtensions = [...]string{
|
||||
|
|
|
@ -35,7 +35,7 @@ func main() {
|
|||
// http://localhost:8080/1
|
||||
// http://localhost:8080/2
|
||||
// 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
|
||||
|
|
|
@ -124,5 +124,5 @@ func main() {
|
|||
})
|
||||
|
||||
// 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))
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ func main() {
|
|||
})
|
||||
|
||||
// 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) {
|
||||
|
|
|
@ -110,5 +110,5 @@ func newApp() *iris.Application {
|
|||
|
||||
func main() {
|
||||
app := newApp()
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -50,5 +50,5 @@ func main() {
|
|||
}
|
||||
})
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -18,5 +18,5 @@ func main() {
|
|||
app := newApp()
|
||||
// http://localhost:8080
|
||||
// http://localhost:8080/yourname
|
||||
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed))
|
||||
app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed))
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -187,5 +187,5 @@ func main() {
|
|||
|
||||
// http://localhost:8080
|
||||
// http://localhost:8080/events
|
||||
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed))
|
||||
app.Listen(":8080", iris.WithoutServerError(iris.ErrServerClosed))
|
||||
}
|
||||
|
|
|
@ -50,5 +50,5 @@ func main() {
|
|||
}
|
||||
})
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -50,5 +50,5 @@ func main() {
|
|||
"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")
|
||||
}
|
||||
|
|
|
@ -17,5 +17,5 @@ func main() {
|
|||
ctx.GzipResponseWriter().WriteString("Hello World!")
|
||||
})
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -91,5 +91,5 @@ func main() {
|
|||
//
|
||||
// `iris.WithoutServerError` is an optional configurator,
|
||||
// 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)
|
||||
}
|
||||
|
|
|
@ -85,5 +85,5 @@ 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"))
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ func main() {
|
|||
|
||||
// Navigate to http://localhost:8080/ping
|
||||
// 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())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,5 +17,5 @@ func main() {
|
|||
app.Any("/debug/pprof", p)
|
||||
app.Any("/debug/pprof/{action:path}", p)
|
||||
// ___________
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ func main() {
|
|||
// pass the middleware before the main handler or use the `recaptcha.SiteVerify`.
|
||||
app.Post("/comment", r, postComment)
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
||||
var htmlForm = `<form action="/comment" method="POST">
|
||||
|
|
|
@ -36,5 +36,5 @@ func main() {
|
|||
ctx.Writef("succeed.")
|
||||
})
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ func main() {
|
|||
})
|
||||
|
||||
// http://localhost:8080, refresh it 5-6 times.
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
||||
// Note:
|
||||
|
|
|
@ -16,7 +16,7 @@ func main() {
|
|||
app.Logger().SetLevel("debug")
|
||||
mvc.Configure(app.Party("/basic"), basicMVC)
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
||||
func basicMVC(app *mvc.Application) {
|
||||
|
|
|
@ -23,7 +23,7 @@ func main() {
|
|||
mvcApp.Handle(new(myController))
|
||||
|
||||
// http://localhost:8080
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
||||
type myController struct {
|
||||
|
|
|
@ -50,7 +50,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".
|
||||
|
|
|
@ -20,7 +20,7 @@ func main() {
|
|||
// http://localhost:8080/other
|
||||
//
|
||||
// refresh every 10 seconds and you'll see different time output.
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
||||
func configure(m *mvc.Application) {
|
||||
|
|
|
@ -84,7 +84,7 @@ func main() {
|
|||
m := mvc.New(app)
|
||||
m.Handle(&exampleController{})
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
||||
type exampleController struct{}
|
||||
|
|
|
@ -51,7 +51,7 @@ func main() {
|
|||
|
||||
m.Handle(&exampleController{})
|
||||
|
||||
app.Run(iris.Addr(":8080"))
|
||||
app.Listen(":8080")
|
||||
}
|
||||
|
||||
func doneHandler(ctx iris.Context) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user