1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-17 09:57:01 +00:00

new NonBlocking option and Wait method on Application. See HISTORY.md for more

This commit is contained in:
Gerasimos (Makis) Maropoulos
2024-01-14 06:58:17 +02:00
parent 5ef854d835
commit 70882914d4
5 changed files with 174 additions and 4 deletions

View File

@@ -216,6 +216,13 @@ func WithTimeout(timeoutDur time.Duration, htmlBody ...string) Configurator {
}
}
// NonBlocking sets the `Configuration.NonBlocking` field to true.
func NonBlocking() Configurator {
return func(app *Application) {
app.config.NonBlocking = true
}
}
// WithoutServerError will cause to ignore the matched "errors"
// from the main application's `Run/Listen` function.
//
@@ -677,6 +684,10 @@ type Configuration struct {
// TimeoutMessage specifies the HTML body when a handler hits its life time based
// on the Timeout configuration field.
TimeoutMessage string `ini:"timeout_message" json:"timeoutMessage" yaml:"TimeoutMessage" toml:"TimeoutMessage"`
// NonBlocking, if set to true then the server will start listening for incoming connections
// without blocking the main goroutine. Use the Application.Wait method to block and wait for the server to be up and running.
NonBlocking bool `ini:"non_blocking" json:"nonBlocking" yaml:"NonBlocking" toml:"NonBlocking"`
// Tunneling can be optionally set to enable ngrok http(s) tunneling for this Iris app instance.
// See the `WithTunneling` Configurator too.
Tunneling TunnelingConfiguration `ini:"tunneling" json:"tunneling,omitempty" yaml:"Tunneling" toml:"Tunneling"`
@@ -994,6 +1005,11 @@ func (c *Configuration) GetTimeout() time.Duration {
return c.Timeout
}
// GetNonBlocking returns the NonBlocking field.
func (c *Configuration) GetNonBlocking() bool {
return c.NonBlocking
}
// GetTimeoutMessage returns the TimeoutMessage field.
func (c *Configuration) GetTimeoutMessage() string {
return c.TimeoutMessage
@@ -1201,6 +1217,10 @@ func WithConfiguration(c Configuration) Configurator {
main.TimeoutMessage = v
}
if v := c.NonBlocking; v {
main.NonBlocking = v
}
if len(c.Tunneling.Tunnels) > 0 {
main.Tunneling = c.Tunneling
}
@@ -1375,6 +1395,7 @@ func DefaultConfiguration() Configuration {
KeepAlive: 0,
Timeout: 0,
TimeoutMessage: DefaultTimeoutMessage,
NonBlocking: false,
DisableStartupLog: false,
DisableInterruptHandler: false,
DisablePathCorrection: false,