2017-02-14 04:54:11 +01:00
|
|
|
package iris
|
2016-05-30 16:08:09 +02:00
|
|
|
|
|
|
|
import (
|
2017-06-10 02:31:50 +02:00
|
|
|
stdContext "context"
|
2019-10-24 17:57:05 +02:00
|
|
|
"errors"
|
2019-07-17 23:53:30 +02:00
|
|
|
"fmt"
|
2017-02-14 04:54:11 +01:00
|
|
|
"io"
|
2016-09-07 06:36:23 +02:00
|
|
|
"log"
|
2016-09-27 15:28:38 +02:00
|
|
|
"net"
|
2017-01-02 20:20:17 +01:00
|
|
|
"net/http"
|
2019-12-13 22:06:18 +01:00
|
|
|
"os"
|
2019-07-17 23:53:30 +02:00
|
|
|
"strings"
|
2016-09-07 06:36:23 +02:00
|
|
|
"sync"
|
|
|
|
"time"
|
2016-10-02 02:30:37 +02:00
|
|
|
|
2020-08-12 22:41:20 +02:00
|
|
|
"github.com/kataras/iris/context"
|
|
|
|
"github.com/kataras/iris/core/errgroup"
|
|
|
|
"github.com/kataras/iris/core/host"
|
|
|
|
"github.com/kataras/iris/core/netutil"
|
|
|
|
"github.com/kataras/iris/core/router"
|
|
|
|
"github.com/kataras/iris/i18n"
|
|
|
|
requestLogger "github.com/kataras/iris/middleware/logger"
|
|
|
|
"github.com/kataras/iris/middleware/recover"
|
|
|
|
"github.com/kataras/iris/view"
|
2020-09-03 20:13:20 +02:00
|
|
|
"github.com/kataras/pio"
|
2020-01-09 07:15:01 +01:00
|
|
|
|
|
|
|
"github.com/kataras/golog"
|
2020-07-10 22:21:09 +02:00
|
|
|
"github.com/kataras/tunnel"
|
2016-05-30 16:08:09 +02:00
|
|
|
)
|
|
|
|
|
2019-08-17 09:06:20 +02:00
|
|
|
// Version is the current version number of the Iris Web Framework.
|
2020-08-12 22:41:20 +02:00
|
|
|
const Version = "stale"
|
|
|
|
|
|
|
|
func init() {
|
2020-09-03 20:13:20 +02:00
|
|
|
fmt.Println(`You have installed an invalid version. Install with:
|
|
|
|
go get -u github.com/kataras/iris/v12@latest
|
2020-08-12 22:41:20 +02:00
|
|
|
|
2020-09-03 20:13:20 +02:00
|
|
|
If your Open Source project depends on that pre-go1.9 version please open an issue
|
|
|
|
at https://github.com/kataras/iris/issues/new and share your repository with us,
|
|
|
|
we will upgrade your project's code base to the latest version for free.
|
2020-08-12 22:41:20 +02:00
|
|
|
|
2020-09-03 20:13:20 +02:00
|
|
|
If you have a commercial project that you cannot share publically, please contact with
|
|
|
|
@kataras at https://chat.iris-go.com. Assistance will be provided to you and your colleagues
|
|
|
|
for free.
|
|
|
|
`)
|
2020-08-12 22:41:20 +02:00
|
|
|
|
2020-09-03 20:13:20 +02:00
|
|
|
fmt.Print("Run ")
|
|
|
|
pio.WriteRich(os.Stdout, "autofix", pio.Green, pio.Underline)
|
|
|
|
fmt.Print("? (Y/n): ")
|
|
|
|
var input string
|
|
|
|
_, err := fmt.Scanln(&input)
|
|
|
|
if err != nil {
|
|
|
|
golog.Fatalf("can not take input from user: %v", err)
|
|
|
|
}
|
|
|
|
input = strings.ToLower(input)
|
|
|
|
if input == "" || input == "y" {
|
|
|
|
err := tryFix()
|
|
|
|
if err != nil {
|
|
|
|
golog.Fatalf("autofix: %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
golog.Infof("OK. Restart the application manually now.")
|
|
|
|
os.Exit(0)
|
|
|
|
} else {
|
|
|
|
os.Exit(-1)
|
|
|
|
}
|
2020-08-12 22:41:20 +02:00
|
|
|
}
|
2017-07-10 17:32:42 +02:00
|
|
|
|
2020-07-10 22:21:09 +02:00
|
|
|
// Byte unit helpers.
|
2017-06-05 02:27:35 +02:00
|
|
|
const (
|
2020-07-10 22:21:09 +02:00
|
|
|
B = 1 << (10 * iota)
|
|
|
|
KB
|
|
|
|
MB
|
|
|
|
GB
|
|
|
|
TB
|
|
|
|
PB
|
|
|
|
EB
|
2017-06-05 02:27:35 +02:00
|
|
|
)
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
|
|
|
|
// Application is responsible to manage the state of the application.
|
|
|
|
// It contains and handles all the necessary parts to create a fast web server.
|
|
|
|
type Application struct {
|
|
|
|
// routing embedded | exposing APIBuilder's and Router's public API.
|
|
|
|
*router.APIBuilder
|
|
|
|
*router.Router
|
2020-05-10 23:44:54 +02:00
|
|
|
router.HTTPErrorHandler // if Router is Downgraded this is nil.
|
|
|
|
ContextPool *context.Pool
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
|
|
|
|
// config contains the configuration fields
|
2017-02-17 01:55:26 +01:00
|
|
|
// all fields defaults to something that is working, developers don't have to set it.
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
config *Configuration
|
2017-02-17 01:55:26 +01:00
|
|
|
|
2017-07-26 14:30:20 +02:00
|
|
|
// the golog logger instance, defaults to "Info" level messages (all except "Debug")
|
|
|
|
logger *golog.Logger
|
2017-02-14 04:54:11 +01:00
|
|
|
|
2019-12-13 22:06:18 +01:00
|
|
|
// I18n contains localization and internationalization support.
|
|
|
|
// Use the `Load` or `LoadAssets` to locale language files.
|
|
|
|
//
|
|
|
|
// See `Context#Tr` method for request-based translations.
|
|
|
|
I18n *i18n.I18n
|
|
|
|
|
2020-04-09 18:02:08 +02:00
|
|
|
// Validator is the request body validator, defaults to nil.
|
|
|
|
Validator context.Validator
|
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// view engine
|
|
|
|
view view.View
|
|
|
|
// used for build
|
2019-12-25 12:12:20 +01:00
|
|
|
builded bool
|
|
|
|
defaultMode bool
|
2017-06-10 02:31:50 +02:00
|
|
|
|
2017-07-10 17:32:42 +02:00
|
|
|
mu sync.Mutex
|
|
|
|
// Hosts contains a list of all servers (Host Supervisors) that this app is running on.
|
|
|
|
//
|
|
|
|
// Hosts may be empty only if application ran(`app.Run`) with `iris.Raw` option runner,
|
|
|
|
// otherwise it contains a single host (`app.Hosts[0]`).
|
|
|
|
//
|
|
|
|
// Additional Host Supervisors can be added to that list by calling the `app.NewHost` manually.
|
|
|
|
//
|
|
|
|
// Hosts field is available after `Run` or `NewHost`.
|
2017-07-31 18:11:58 +02:00
|
|
|
Hosts []*host.Supervisor
|
|
|
|
hostConfigurators []host.Configurator
|
2017-02-14 04:54:11 +01:00
|
|
|
}
|
2016-09-09 07:09:03 +02:00
|
|
|
|
2017-07-10 17:32:42 +02:00
|
|
|
// New creates and returns a fresh empty iris *Application instance.
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
func New() *Application {
|
|
|
|
config := DefaultConfiguration()
|
2016-10-02 02:30:37 +02:00
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
app := &Application{
|
|
|
|
config: &config,
|
2017-07-26 14:30:20 +02:00
|
|
|
logger: golog.Default,
|
2019-12-13 22:06:18 +01:00
|
|
|
I18n: i18n.New(),
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
APIBuilder: router.NewAPIBuilder(),
|
|
|
|
Router: router.NewRouter(),
|
2016-07-06 20:24:34 +02:00
|
|
|
}
|
2016-05-30 16:08:09 +02:00
|
|
|
|
2020-07-10 22:21:09 +02:00
|
|
|
app.ContextPool = context.New(func() interface{} {
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
return context.NewContext(app)
|
|
|
|
})
|
2016-06-14 19:29:01 +02:00
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
return app
|
2016-09-27 15:28:38 +02:00
|
|
|
}
|
2016-08-17 11:57:54 +02:00
|
|
|
|
2019-12-25 12:12:20 +01:00
|
|
|
// Default returns a new Application instance which on build state registers
|
|
|
|
// html view engine on "./views" and load locales from "./locales/*/*".
|
2019-12-13 22:06:18 +01:00
|
|
|
// The return instance recovers on panics and logs the incoming http requests too.
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
func Default() *Application {
|
|
|
|
app := New()
|
|
|
|
app.Use(recover.New())
|
|
|
|
app.Use(requestLogger.New())
|
2020-07-20 12:36:39 +02:00
|
|
|
app.Use(Compression)
|
2020-07-05 04:39:48 +02:00
|
|
|
|
2019-12-25 12:12:20 +01:00
|
|
|
app.defaultMode = true
|
2019-12-13 22:06:18 +01:00
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
return app
|
2016-07-06 20:24:34 +02:00
|
|
|
}
|
|
|
|
|
2018-01-20 04:17:31 +01:00
|
|
|
// WWW creates and returns a "www." subdomain.
|
|
|
|
// The difference from `app.Subdomain("www")` or `app.Party("www.")` is that the `app.WWW()` method
|
|
|
|
// wraps the router so all http(s)://mydomain.com will be redirect to http(s)://www.mydomain.com.
|
|
|
|
// Other subdomains can be registered using the app: `sub := app.Subdomain("mysubdomain")`,
|
|
|
|
// child subdomains can be registered using the www := app.WWW(); www.Subdomain("wwwchildSubdomain").
|
|
|
|
func (app *Application) WWW() router.Party {
|
|
|
|
return app.SubdomainRedirect(app, app.Subdomain("www"))
|
|
|
|
}
|
|
|
|
|
|
|
|
// SubdomainRedirect registers a router wrapper which
|
|
|
|
// redirects(StatusMovedPermanently) a (sub)domain to another subdomain or to the root domain as fast as possible,
|
|
|
|
// before the router's try to execute route's handler(s).
|
|
|
|
//
|
|
|
|
// It receives two arguments, they are the from and to/target locations,
|
|
|
|
// 'from' can be a wildcard subdomain as well (app.WildcardSubdomain())
|
|
|
|
// 'to' is not allowed to be a wildcard for obvious reasons,
|
|
|
|
// 'from' can be the root domain(app) when the 'to' is not the root domain and visa-versa.
|
|
|
|
//
|
|
|
|
// Usage:
|
|
|
|
// www := app.Subdomain("www") <- same as app.Party("www.")
|
|
|
|
// app.SubdomainRedirect(app, www)
|
|
|
|
// This will redirect all http(s)://mydomain.com/%anypath% to http(s)://www.mydomain.com/%anypath%.
|
|
|
|
//
|
|
|
|
// One or more subdomain redirects can be used to the same app instance.
|
|
|
|
//
|
|
|
|
// If you need more information about this implementation then you have to navigate through
|
|
|
|
// the `core/router#NewSubdomainRedirectWrapper` function instead.
|
|
|
|
//
|
2020-06-07 14:26:06 +02:00
|
|
|
// Example: https://github.com/kataras/iris/tree/master/_examples/routing/subdomains/redirect
|
2018-01-20 04:17:31 +01:00
|
|
|
func (app *Application) SubdomainRedirect(from, to router.Party) router.Party {
|
|
|
|
sd := router.NewSubdomainRedirectWrapper(app.ConfigurationReadOnly().GetVHost, from.GetRelPath(), to.GetRelPath())
|
2020-06-10 22:37:50 +02:00
|
|
|
app.Router.WrapRouter(sd)
|
2018-01-20 04:17:31 +01:00
|
|
|
return to
|
|
|
|
}
|
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// Configure can called when modifications to the framework instance needed.
|
|
|
|
// It accepts the framework instance
|
|
|
|
// and returns an error which if it's not nil it's printed to the logger.
|
|
|
|
// See configuration.go for more.
|
|
|
|
//
|
2017-07-10 17:32:42 +02:00
|
|
|
// Returns itself in order to be used like `app:= New().Configure(...)`
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
func (app *Application) Configure(configurators ...Configurator) *Application {
|
|
|
|
for _, cfg := range configurators {
|
2019-07-16 15:10:46 +02:00
|
|
|
if cfg != nil {
|
|
|
|
cfg(app)
|
|
|
|
}
|
2017-02-17 03:46:33 +01:00
|
|
|
}
|
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
return app
|
2016-09-18 05:55:44 +02:00
|
|
|
}
|
|
|
|
|
2017-07-10 17:32:42 +02:00
|
|
|
// ConfigurationReadOnly returns an object which doesn't allow field writing.
|
|
|
|
func (app *Application) ConfigurationReadOnly() context.ConfigurationReadOnly {
|
|
|
|
return app.config
|
|
|
|
}
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
|
2017-07-26 14:30:20 +02:00
|
|
|
// Logger returns the golog logger instance(pointer) that is being used inside the "app".
|
2017-08-02 03:22:15 +02:00
|
|
|
//
|
|
|
|
// Available levels:
|
|
|
|
// - "disable"
|
2017-08-02 14:10:02 +02:00
|
|
|
// - "fatal"
|
2017-08-02 03:22:15 +02:00
|
|
|
// - "error"
|
|
|
|
// - "warn"
|
|
|
|
// - "info"
|
|
|
|
// - "debug"
|
|
|
|
// Usage: app.Logger().SetLevel("error")
|
2020-05-08 02:55:54 +02:00
|
|
|
// Or set the level through Configurartion's LogLevel or WithLogLevel functional option.
|
2017-08-02 03:22:15 +02:00
|
|
|
// Defaults to "info" level.
|
|
|
|
//
|
|
|
|
// Callers can use the application's logger which is
|
|
|
|
// the same `golog.Default` logger,
|
|
|
|
// to print custom logs too.
|
|
|
|
// Usage:
|
|
|
|
// app.Logger().Error/Errorf("...")
|
|
|
|
// app.Logger().Warn/Warnf("...")
|
|
|
|
// app.Logger().Info/Infof("...")
|
|
|
|
// app.Logger().Debug/Debugf("...")
|
|
|
|
//
|
|
|
|
// Setting one or more outputs: app.Logger().SetOutput(io.Writer...)
|
|
|
|
// Adding one or more outputs : app.Logger().AddOutput(io.Writer...)
|
|
|
|
//
|
|
|
|
// Adding custom levels requires import of the `github.com/kataras/golog` package:
|
|
|
|
// First we create our level to a golog.Level
|
|
|
|
// in order to be used in the Log functions.
|
2017-08-02 14:10:02 +02:00
|
|
|
// var SuccessLevel golog.Level = 6
|
2017-08-02 03:22:15 +02:00
|
|
|
// Register our level, just three fields.
|
|
|
|
// golog.Levels[SuccessLevel] = &golog.LevelMetadata{
|
|
|
|
// Name: "success",
|
|
|
|
// RawText: "[SUCC]",
|
|
|
|
// // ColorfulText (Green Color[SUCC])
|
|
|
|
// ColorfulText: "\x1b[32m[SUCC]\x1b[0m",
|
|
|
|
// }
|
|
|
|
// Usage:
|
|
|
|
// app.Logger().SetLevel("success")
|
|
|
|
// app.Logger().Logf(SuccessLevel, "a custom leveled log message")
|
2017-07-26 14:30:20 +02:00
|
|
|
func (app *Application) Logger() *golog.Logger {
|
2017-07-10 17:32:42 +02:00
|
|
|
return app.logger
|
|
|
|
}
|
2016-07-06 20:24:34 +02:00
|
|
|
|
2019-12-13 22:06:18 +01:00
|
|
|
// I18nReadOnly returns the i18n's read-only features.
|
|
|
|
// See `I18n` method for more.
|
|
|
|
func (app *Application) I18nReadOnly() context.I18nReadOnly {
|
|
|
|
return app.I18n
|
|
|
|
}
|
|
|
|
|
2020-04-09 18:02:08 +02:00
|
|
|
// Validate validates a value and returns nil if passed or
|
|
|
|
// the failure reason if does not.
|
|
|
|
func (app *Application) Validate(v interface{}) error {
|
|
|
|
if app.Validator == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// val := reflect.ValueOf(v)
|
|
|
|
// if val.Kind() == reflect.Ptr && !val.IsNil() {
|
|
|
|
// val = val.Elem()
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if val.Kind() == reflect.Struct && val.Type() != timeType {
|
|
|
|
// return app.Validator.Struct(v)
|
|
|
|
// }
|
|
|
|
|
|
|
|
// no need to check the kind, underline lib does it but in the future this may change (look above).
|
|
|
|
err := app.Validator.Struct(v)
|
|
|
|
if err != nil {
|
|
|
|
if !strings.HasPrefix(err.Error(), "validator: ") {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-07-10 17:32:42 +02:00
|
|
|
// RegisterView should be used to register view engines mapping to a root directory
|
|
|
|
// and the template file(s) extension.
|
|
|
|
func (app *Application) RegisterView(viewEngine view.Engine) {
|
|
|
|
app.view.Register(viewEngine)
|
|
|
|
}
|
|
|
|
|
|
|
|
// View executes and writes the result of a template file to the writer.
|
|
|
|
//
|
|
|
|
// First parameter is the writer to write the parsed template.
|
|
|
|
// Second parameter is the relative, to templates directory, template filename, including extension.
|
|
|
|
// Third parameter is the layout, can be empty string.
|
|
|
|
// Forth parameter is the bindable data to the template, can be nil.
|
|
|
|
//
|
|
|
|
// Use context.View to render templates to the client instead.
|
|
|
|
// Returns an error on failure, otherwise nil.
|
|
|
|
func (app *Application) View(writer io.Writer, filename string, layout string, bindingData interface{}) error {
|
|
|
|
if app.view.Len() == 0 {
|
|
|
|
err := errors.New("view engine is missing, use `RegisterView`")
|
2020-06-10 22:37:50 +02:00
|
|
|
app.logger.Error(err)
|
2017-07-10 17:32:42 +02:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
err := app.view.ExecuteWriter(writer, filename, layout, bindingData)
|
|
|
|
if err != nil {
|
2020-06-10 22:37:50 +02:00
|
|
|
app.logger.Error(err)
|
2017-07-10 17:32:42 +02:00
|
|
|
}
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-07-31 18:11:58 +02:00
|
|
|
// ConfigureHost accepts one or more `host#Configuration`, these configurators functions
|
2020-08-05 18:34:55 +02:00
|
|
|
// can access the host created by `app.Run` or `app.Listen`,
|
2017-07-31 18:11:58 +02:00
|
|
|
// they're being executed when application is ready to being served to the public.
|
|
|
|
//
|
|
|
|
// It's an alternative way to interact with a host that is automatically created by
|
|
|
|
// `app.Run`.
|
|
|
|
//
|
|
|
|
// These "configurators" can work side-by-side with the `iris#Addr, iris#Server, iris#TLS, iris#AutoTLS, iris#Listener`
|
|
|
|
// final arguments("hostConfigs") too.
|
|
|
|
//
|
|
|
|
// Note that these application's host "configurators" will be shared with the rest of
|
|
|
|
// the hosts that this app will may create (using `app.NewHost`), meaning that
|
|
|
|
// `app.NewHost` will execute these "configurators" everytime that is being called as well.
|
|
|
|
//
|
|
|
|
// These "configurators" should be registered before the `app.Run` or `host.Serve/Listen` functions.
|
|
|
|
func (app *Application) ConfigureHost(configurators ...host.Configurator) *Application {
|
|
|
|
app.mu.Lock()
|
|
|
|
app.hostConfigurators = append(app.hostConfigurators, configurators...)
|
|
|
|
app.mu.Unlock()
|
|
|
|
return app
|
|
|
|
}
|
|
|
|
|
2020-01-08 05:56:35 +01:00
|
|
|
// NewHost accepts a standard *http.Server object,
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// completes the necessary missing parts of that "srv"
|
|
|
|
// and returns a new, ready-to-use, host (supervisor).
|
|
|
|
func (app *Application) NewHost(srv *http.Server) *host.Supervisor {
|
2017-06-10 02:31:50 +02:00
|
|
|
app.mu.Lock()
|
|
|
|
defer app.mu.Unlock()
|
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// set the server's handler to the framework's router
|
|
|
|
if srv.Handler == nil {
|
|
|
|
srv.Handler = app.Router
|
2017-02-17 05:49:54 +01:00
|
|
|
}
|
2017-01-11 15:23:38 +01:00
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// check if different ErrorLog provided, if not bind it with the framework's logger
|
|
|
|
if srv.ErrorLog == nil {
|
2017-07-26 14:30:20 +02:00
|
|
|
srv.ErrorLog = log.New(app.logger.Printer.Output, "[HTTP Server] ", 0)
|
2017-02-14 04:54:11 +01:00
|
|
|
}
|
2017-02-17 05:49:54 +01:00
|
|
|
|
2020-02-05 11:36:21 +01:00
|
|
|
if addr := srv.Addr; addr == "" {
|
|
|
|
addr = ":8080"
|
|
|
|
if len(app.Hosts) > 0 {
|
|
|
|
if v := app.Hosts[0].Server.Addr; v != "" {
|
|
|
|
addr = v
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
srv.Addr = addr
|
2017-02-17 03:46:33 +01:00
|
|
|
}
|
2020-02-05 11:36:21 +01:00
|
|
|
|
2020-04-26 05:21:20 +02:00
|
|
|
// app.logger.Debugf("Host: addr is %s", srv.Addr)
|
2017-01-11 15:23:38 +01:00
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// create the new host supervisor
|
|
|
|
// bind the constructed server and return it
|
|
|
|
su := host.New(srv)
|
2017-02-17 05:49:54 +01:00
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
if app.config.vhost == "" { // vhost now is useful for router subdomain on wildcard subdomains,
|
|
|
|
// in order to correct decide what to do on:
|
|
|
|
// mydomain.com -> invalid
|
|
|
|
// localhost -> invalid
|
|
|
|
// sub.mydomain.com -> valid
|
|
|
|
// sub.localhost -> valid
|
|
|
|
// we need the host (without port if 80 or 443) in order to validate these, so:
|
2017-07-10 17:32:42 +02:00
|
|
|
app.config.vhost = netutil.ResolveVHost(srv.Addr)
|
2017-02-17 05:49:54 +01:00
|
|
|
}
|
2017-08-02 03:22:15 +02:00
|
|
|
|
2020-04-26 05:21:20 +02:00
|
|
|
// app.logger.Debugf("Host: virtual host is %s", app.config.vhost)
|
2017-08-02 03:22:15 +02:00
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// the below schedules some tasks that will run among the server
|
2017-02-17 05:49:54 +01:00
|
|
|
|
2017-07-10 17:32:42 +02:00
|
|
|
if !app.config.DisableStartupLog {
|
|
|
|
// show the available info to exit from app.
|
2017-07-26 14:30:20 +02:00
|
|
|
su.RegisterOnServe(host.WriteStartupLogOnServe(app.logger.Printer.Output)) // app.logger.Writer -> Info
|
2020-04-26 05:21:20 +02:00
|
|
|
// app.logger.Debugf("Host: register startup notifier")
|
2017-02-28 04:37:53 +01:00
|
|
|
}
|
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
if !app.config.DisableInterruptHandler {
|
2020-04-28 04:22:58 +02:00
|
|
|
// when CTRL/CMD+C pressed.
|
|
|
|
shutdownTimeout := 10 * time.Second
|
2017-07-10 17:32:42 +02:00
|
|
|
host.RegisterOnInterrupt(host.ShutdownOnInterrupt(su, shutdownTimeout))
|
2020-04-26 05:21:20 +02:00
|
|
|
// app.logger.Debugf("Host: register server shutdown on interrupt(CTRL+C/CMD+C)")
|
2016-09-27 15:28:38 +02:00
|
|
|
}
|
|
|
|
|
2017-07-13 15:31:36 +02:00
|
|
|
su.IgnoredErrors = append(su.IgnoredErrors, app.config.IgnoreServerErrors...)
|
2017-11-04 01:59:21 +01:00
|
|
|
if len(su.IgnoredErrors) > 0 {
|
|
|
|
app.logger.Debugf("Host: server will ignore the following errors: %s", su.IgnoredErrors)
|
|
|
|
}
|
|
|
|
|
2017-07-31 18:11:58 +02:00
|
|
|
su.Configure(app.hostConfigurators...)
|
|
|
|
|
2017-07-10 17:32:42 +02:00
|
|
|
app.Hosts = append(app.Hosts, su)
|
2017-06-10 02:31:50 +02:00
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
return su
|
2016-06-14 07:45:40 +02:00
|
|
|
}
|
2016-05-30 16:08:09 +02:00
|
|
|
|
2020-02-02 15:29:06 +01:00
|
|
|
// Shutdown gracefully terminates all the application's server hosts and any tunnels.
|
2017-07-10 17:32:42 +02:00
|
|
|
// Returns an error on the first failure, otherwise nil.
|
|
|
|
func (app *Application) Shutdown(ctx stdContext.Context) error {
|
2020-06-09 09:09:04 +02:00
|
|
|
app.mu.Lock()
|
|
|
|
defer app.mu.Unlock()
|
|
|
|
|
2020-02-02 15:29:06 +01:00
|
|
|
for i, su := range app.Hosts {
|
|
|
|
app.logger.Debugf("Host[%d]: Shutdown now", i)
|
|
|
|
if err := su.Shutdown(ctx); err != nil {
|
|
|
|
app.logger.Debugf("Host[%d]: Error while trying to shutdown", i)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-17 23:53:30 +02:00
|
|
|
for _, t := range app.config.Tunneling.Tunnels {
|
|
|
|
if t.Name == "" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2020-07-10 22:21:09 +02:00
|
|
|
if err := app.config.Tunneling.StopTunnel(t); err != nil {
|
2017-07-10 17:32:42 +02:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2020-02-02 15:29:06 +01:00
|
|
|
|
2017-07-10 17:32:42 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-02-10 18:40:17 +01:00
|
|
|
// Build sets up, once, the framework.
|
|
|
|
// It builds the default router with its default macros
|
|
|
|
// and the template functions that are very-closed to iris.
|
|
|
|
//
|
|
|
|
// If error occurred while building the Application, the returns type of error will be an *errgroup.Group
|
|
|
|
// which let the callers to inspect the errors and cause, usage:
|
|
|
|
//
|
2020-08-12 22:41:20 +02:00
|
|
|
// import "github.com/kataras/iris/core/errgroup"
|
2020-02-10 18:40:17 +01:00
|
|
|
//
|
|
|
|
// errgroup.Walk(app.Build(), func(typ interface{}, err error) {
|
|
|
|
// app.Logger().Errorf("%s: %s", typ, err)
|
|
|
|
// })
|
|
|
|
func (app *Application) Build() error {
|
2020-04-29 04:50:29 +02:00
|
|
|
if app.builded {
|
|
|
|
return nil
|
|
|
|
}
|
2020-04-30 15:16:43 +02:00
|
|
|
// start := time.Now()
|
2020-04-29 04:50:29 +02:00
|
|
|
app.builded = true // even if fails.
|
2020-02-10 18:40:17 +01:00
|
|
|
|
2020-05-08 02:55:54 +02:00
|
|
|
// check if a prior app.Logger().SetLevel called and if not
|
|
|
|
// then set the defined configuration's log level.
|
|
|
|
if app.logger.Level == golog.InfoLevel /* the default level */ {
|
|
|
|
app.logger.SetLevel(app.config.LogLevel)
|
|
|
|
}
|
|
|
|
|
2020-04-29 04:50:29 +02:00
|
|
|
rp := errgroup.New("Application Builder")
|
|
|
|
rp.Err(app.APIBuilder.GetReporter())
|
2020-02-10 18:40:17 +01:00
|
|
|
|
2020-04-29 04:50:29 +02:00
|
|
|
if app.defaultMode { // the app.I18n and app.View will be not available until Build.
|
|
|
|
if !app.I18n.Loaded() {
|
|
|
|
for _, s := range []string{"./locales/*/*", "./locales/*", "./translations"} {
|
|
|
|
if _, err := os.Stat(s); os.IsNotExist(err) {
|
|
|
|
continue
|
|
|
|
}
|
2020-02-10 18:40:17 +01:00
|
|
|
|
2020-04-29 04:50:29 +02:00
|
|
|
if err := app.I18n.Load(s); err != nil {
|
|
|
|
continue
|
2020-02-10 18:40:17 +01:00
|
|
|
}
|
|
|
|
|
2020-04-29 04:50:29 +02:00
|
|
|
app.I18n.SetDefault("en-US")
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
2020-02-10 18:40:17 +01:00
|
|
|
|
2020-04-29 04:50:29 +02:00
|
|
|
if app.view.Len() == 0 {
|
|
|
|
for _, s := range []string{"./views", "./templates", "./web/views"} {
|
|
|
|
if _, err := os.Stat(s); os.IsNotExist(err) {
|
|
|
|
continue
|
2020-02-10 18:40:17 +01:00
|
|
|
}
|
2020-04-29 04:50:29 +02:00
|
|
|
|
|
|
|
app.RegisterView(HTML(s, ".html"))
|
|
|
|
break
|
2020-02-10 18:40:17 +01:00
|
|
|
}
|
|
|
|
}
|
2020-04-29 04:50:29 +02:00
|
|
|
}
|
2020-02-10 18:40:17 +01:00
|
|
|
|
2020-04-29 04:50:29 +02:00
|
|
|
if app.I18n.Loaded() {
|
|
|
|
// {{ tr "lang" "key" arg1 arg2 }}
|
|
|
|
app.view.AddFunc("tr", app.I18n.Tr)
|
|
|
|
app.Router.WrapRouter(app.I18n.Wrapper())
|
|
|
|
}
|
2020-02-10 18:40:17 +01:00
|
|
|
|
2020-04-29 04:50:29 +02:00
|
|
|
if n := app.view.Len(); n > 0 {
|
|
|
|
tr := "engines"
|
|
|
|
if n == 1 {
|
|
|
|
tr = tr[0 : len(tr)-1]
|
|
|
|
}
|
2020-04-28 04:42:23 +02:00
|
|
|
|
2020-04-29 04:50:29 +02:00
|
|
|
app.logger.Debugf("Application: %d registered view %s", n, tr)
|
|
|
|
// view engine
|
|
|
|
// here is where we declare the closed-relative framework functions.
|
|
|
|
// Each engine has their defaults, i.e yield,render,render_r,partial, params...
|
|
|
|
rv := router.NewRoutePathReverser(app.APIBuilder)
|
|
|
|
app.view.AddFunc("urlpath", rv.Path)
|
|
|
|
// app.view.AddFunc("url", rv.URL)
|
|
|
|
if err := app.view.Load(); err != nil {
|
|
|
|
rp.Group("View Builder").Err(err)
|
2020-04-28 04:42:23 +02:00
|
|
|
}
|
2020-04-29 04:50:29 +02:00
|
|
|
}
|
2020-04-28 04:42:23 +02:00
|
|
|
|
2020-04-29 04:50:29 +02:00
|
|
|
if !app.Router.Downgraded() {
|
|
|
|
// router
|
2020-07-10 22:21:09 +02:00
|
|
|
if _, err := injectLiveReload(app.ContextPool, app.Router); err != nil {
|
2020-04-29 04:50:29 +02:00
|
|
|
rp.Errf("LiveReload: init: failed: %v", err)
|
|
|
|
}
|
2020-02-10 18:40:17 +01:00
|
|
|
|
2020-04-29 04:50:29 +02:00
|
|
|
if app.config.ForceLowercaseRouting {
|
|
|
|
app.Router.WrapRouter(func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
|
|
|
|
r.URL.Path = strings.ToLower(r.URL.Path)
|
|
|
|
next(w, r)
|
|
|
|
})
|
|
|
|
}
|
2020-04-25 01:30:19 +02:00
|
|
|
|
2020-04-29 04:50:29 +02:00
|
|
|
// create the request handler, the default routing handler
|
2020-04-30 15:16:43 +02:00
|
|
|
routerHandler := router.NewDefaultHandler(app.config, app.logger)
|
2020-04-29 04:50:29 +02:00
|
|
|
err := app.Router.BuildRouter(app.ContextPool, routerHandler, app.APIBuilder, false)
|
|
|
|
if err != nil {
|
|
|
|
rp.Err(err)
|
2020-02-10 18:40:17 +01:00
|
|
|
}
|
2020-05-10 23:44:54 +02:00
|
|
|
app.HTTPErrorHandler = routerHandler
|
2020-04-29 04:50:29 +02:00
|
|
|
// re-build of the router from outside can be done with
|
|
|
|
// app.RefreshRouter()
|
2020-02-10 18:40:17 +01:00
|
|
|
}
|
|
|
|
|
2020-04-29 04:50:29 +02:00
|
|
|
// if end := time.Since(start); end.Seconds() > 5 {
|
2020-04-30 15:16:43 +02:00
|
|
|
// app.logger.Debugf("Application: build took %s", time.Since(start))
|
2020-04-29 04:50:29 +02:00
|
|
|
|
2020-02-10 18:40:17 +01:00
|
|
|
return errgroup.Check(rp)
|
|
|
|
}
|
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// Runner is just an interface which accepts the framework instance
|
|
|
|
// and returns an error.
|
|
|
|
//
|
|
|
|
// It can be used to register a custom runner with `Run` in order
|
|
|
|
// to set the framework's server listen action.
|
2016-06-14 07:45:40 +02:00
|
|
|
//
|
2019-02-23 06:23:10 +01:00
|
|
|
// Currently `Runner` is being used to declare the builtin server listeners.
|
2016-06-14 07:45:40 +02:00
|
|
|
//
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// See `Run` for more.
|
|
|
|
type Runner func(*Application) error
|
2016-09-27 15:28:38 +02:00
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// Listener can be used as an argument for the `Run` method.
|
|
|
|
// It can start a server with a custom net.Listener via server's `Serve`.
|
|
|
|
//
|
2017-07-29 03:27:58 +02:00
|
|
|
// Second argument is optional, it accepts one or more
|
|
|
|
// `func(*host.Configurator)` that are being executed
|
|
|
|
// on that specific host that this function will create to start the server.
|
|
|
|
// Via host configurators you can configure the back-end host supervisor,
|
|
|
|
// i.e to add events for shutdown, serve or error.
|
|
|
|
// An example of this use case can be found at:
|
2020-06-07 14:26:06 +02:00
|
|
|
// https://github.com/kataras/iris/blob/master/_examples/http-server/notify-on-shutdown/main.go
|
2017-07-31 18:11:58 +02:00
|
|
|
// Look at the `ConfigureHost` too.
|
2017-07-29 03:27:58 +02:00
|
|
|
//
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// See `Run` for more.
|
2017-07-29 03:27:58 +02:00
|
|
|
func Listener(l net.Listener, hostConfigs ...host.Configurator) Runner {
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
return func(app *Application) error {
|
2017-07-10 17:32:42 +02:00
|
|
|
app.config.vhost = netutil.ResolveVHost(l.Addr().String())
|
2017-09-20 14:15:54 +02:00
|
|
|
return app.NewHost(&http.Server{Addr: l.Addr().String()}).
|
2017-07-29 03:27:58 +02:00
|
|
|
Configure(hostConfigs...).
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
Serve(l)
|
2016-07-07 02:36:48 +02:00
|
|
|
}
|
2016-06-14 07:45:40 +02:00
|
|
|
}
|
2016-06-06 12:25:09 +02:00
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// Server can be used as an argument for the `Run` method.
|
|
|
|
// It can start a server with a *http.Server.
|
2016-10-28 20:21:57 +02:00
|
|
|
//
|
2017-07-29 03:27:58 +02:00
|
|
|
// Second argument is optional, it accepts one or more
|
|
|
|
// `func(*host.Configurator)` that are being executed
|
|
|
|
// on that specific host that this function will create to start the server.
|
|
|
|
// Via host configurators you can configure the back-end host supervisor,
|
|
|
|
// i.e to add events for shutdown, serve or error.
|
|
|
|
// An example of this use case can be found at:
|
2020-06-07 14:26:06 +02:00
|
|
|
// https://github.com/kataras/iris/blob/master/_examples/http-server/notify-on-shutdown/main.go
|
2017-07-31 18:11:58 +02:00
|
|
|
// Look at the `ConfigureHost` too.
|
2017-07-29 03:27:58 +02:00
|
|
|
//
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// See `Run` for more.
|
2017-07-29 03:27:58 +02:00
|
|
|
func Server(srv *http.Server, hostConfigs ...host.Configurator) Runner {
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
return func(app *Application) error {
|
|
|
|
return app.NewHost(srv).
|
2017-07-29 03:27:58 +02:00
|
|
|
Configure(hostConfigs...).
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
ListenAndServe()
|
2016-07-29 00:33:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// Addr can be used as an argument for the `Run` method.
|
|
|
|
// It accepts a host address which is used to build a server
|
|
|
|
// and a listener which listens on that host and port.
|
2016-06-30 04:58:04 +02:00
|
|
|
//
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// Addr should have the form of [host]:port, i.e localhost:8080 or :8080.
|
2017-03-24 01:25:00 +01:00
|
|
|
//
|
2017-07-29 03:27:58 +02:00
|
|
|
// Second argument is optional, it accepts one or more
|
|
|
|
// `func(*host.Configurator)` that are being executed
|
|
|
|
// on that specific host that this function will create to start the server.
|
|
|
|
// Via host configurators you can configure the back-end host supervisor,
|
|
|
|
// i.e to add events for shutdown, serve or error.
|
|
|
|
// An example of this use case can be found at:
|
2020-06-07 14:26:06 +02:00
|
|
|
// https://github.com/kataras/iris/blob/master/_examples/http-server/notify-on-shutdown/main.go
|
2017-07-31 18:11:58 +02:00
|
|
|
// Look at the `ConfigureHost` too.
|
2017-07-29 03:27:58 +02:00
|
|
|
//
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// See `Run` for more.
|
2017-07-29 03:27:58 +02:00
|
|
|
func Addr(addr string, hostConfigs ...host.Configurator) Runner {
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
return func(app *Application) error {
|
|
|
|
return app.NewHost(&http.Server{Addr: addr}).
|
2017-07-29 03:27:58 +02:00
|
|
|
Configure(hostConfigs...).
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
ListenAndServe()
|
2016-09-27 15:28:38 +02:00
|
|
|
}
|
2016-07-05 14:29:32 +02:00
|
|
|
}
|
|
|
|
|
2020-08-12 06:20:07 +02:00
|
|
|
var (
|
|
|
|
// TLSNoRedirect is a `host.Configurator` which can be passed as last argument
|
|
|
|
// to the `TLS` runner function. It disables the automatic
|
|
|
|
// registration of redirection from "http://" to "https://" requests.
|
|
|
|
// Applies only to the `TLS` runner.
|
|
|
|
// See `AutoTLSNoRedirect` to register a custom fallback server for `AutoTLS` runner.
|
|
|
|
TLSNoRedirect = func(su *host.Supervisor) { su.NoRedirect() }
|
|
|
|
// AutoTLSNoRedirect is a `host.Configurator`.
|
|
|
|
// It registers a fallback HTTP/1.1 server for the `AutoTLS` one.
|
|
|
|
// The function accepts the letsencrypt wrapper and it
|
|
|
|
// should return a valid instance of http.Server which its handler should be the result
|
|
|
|
// of the "acmeHandler" wrapper.
|
|
|
|
// Usage:
|
|
|
|
// getServer := func(acme func(http.Handler) http.Handler) *http.Server {
|
|
|
|
// srv := &http.Server{Handler: acme(yourCustomHandler), ...otherOptions}
|
|
|
|
// go srv.ListenAndServe()
|
|
|
|
// return srv
|
|
|
|
// }
|
|
|
|
// app.Run(iris.AutoTLS(":443", "example.com example2.com", "mail@example.com", getServer))
|
|
|
|
//
|
|
|
|
// Note that if Server.Handler is nil then the server is automatically ran
|
|
|
|
// by the framework and the handler set to automatic redirection, it's still
|
|
|
|
// a valid option when the caller wants just to customize the server's fields (except Addr).
|
|
|
|
// With this host configurator the caller can customize the server
|
|
|
|
// that letsencrypt relies to perform the challenge.
|
|
|
|
// LetsEncrypt Certification Manager relies on http://%s:80/.well-known/acme-challenge/<TOKEN>.
|
|
|
|
AutoTLSNoRedirect = func(getFallbackServer func(acmeHandler func(fallback http.Handler) http.Handler) *http.Server) host.Configurator {
|
|
|
|
return func(su *host.Supervisor) {
|
|
|
|
su.NoRedirect()
|
|
|
|
su.Fallback = getFallbackServer
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
2020-05-08 20:13:12 +02:00
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// TLS can be used as an argument for the `Run` method.
|
|
|
|
// It will start the Application's secure server.
|
|
|
|
//
|
|
|
|
// Use it like you used to use the http.ListenAndServeTLS function.
|
:rainbow: sessions were re-written, update to 4.0.0-alpha.2, read HISTORY.md
**Sessions were re-written **
- Developers can use more than one 'session database', at the same time,
to store the sessions
- Easy to develop a custom session database (only two functions are
required (Load & Update)), [learn
more](https://github.com/iris-contrib/sessiondb/blob/master/redis/database.go)
- Session databases are located
[here](https://github.com/iris-contrib/sessiondb), contributions are
welcome
- The only frontend deleted 'thing' is the: **config.Sessions.Provider**
- No need to register a database, the sessions works out-of-the-box
- No frontend/API changes except the
`context.Session().Set/Delete/Clear`, they doesn't return errors
anymore, btw they (errors) were always nil :)
- Examples (master branch) were updated.
```sh
$ go get github.com/iris-contrib/sessiondb/$DATABASE
```
```go
db := $DATABASE.New(configurationHere{})
iris.UseSessionDB(db)
```
> Note: Book is not updated yet, examples are up-to-date as always.
2016-07-15 19:50:36 +02:00
|
|
|
//
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// Addr should have the form of [host]:port, i.e localhost:443 or :443.
|
2020-05-08 20:13:12 +02:00
|
|
|
// "certFileOrContents" & "keyFileOrContents" should be filenames with their extensions
|
|
|
|
// or raw contents of the certificate and the private key.
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
//
|
2020-05-08 20:13:12 +02:00
|
|
|
// Last argument is optional, it accepts one or more
|
2017-07-29 03:27:58 +02:00
|
|
|
// `func(*host.Configurator)` that are being executed
|
|
|
|
// on that specific host that this function will create to start the server.
|
|
|
|
// Via host configurators you can configure the back-end host supervisor,
|
|
|
|
// i.e to add events for shutdown, serve or error.
|
|
|
|
// An example of this use case can be found at:
|
2020-06-07 14:26:06 +02:00
|
|
|
// https://github.com/kataras/iris/blob/master/_examples/http-server/notify-on-shutdown/main.go
|
2017-07-31 18:11:58 +02:00
|
|
|
// Look at the `ConfigureHost` too.
|
2017-07-29 03:27:58 +02:00
|
|
|
//
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// See `Run` for more.
|
2020-05-08 20:13:12 +02:00
|
|
|
func TLS(addr string, certFileOrContents, keyFileOrContents string, hostConfigs ...host.Configurator) Runner {
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
return func(app *Application) error {
|
|
|
|
return app.NewHost(&http.Server{Addr: addr}).
|
2017-07-29 03:27:58 +02:00
|
|
|
Configure(hostConfigs...).
|
2020-05-08 20:13:12 +02:00
|
|
|
ListenAndServeTLS(certFileOrContents, keyFileOrContents)
|
2017-02-14 04:54:11 +01:00
|
|
|
}
|
:rainbow: sessions were re-written, update to 4.0.0-alpha.2, read HISTORY.md
**Sessions were re-written **
- Developers can use more than one 'session database', at the same time,
to store the sessions
- Easy to develop a custom session database (only two functions are
required (Load & Update)), [learn
more](https://github.com/iris-contrib/sessiondb/blob/master/redis/database.go)
- Session databases are located
[here](https://github.com/iris-contrib/sessiondb), contributions are
welcome
- The only frontend deleted 'thing' is the: **config.Sessions.Provider**
- No need to register a database, the sessions works out-of-the-box
- No frontend/API changes except the
`context.Session().Set/Delete/Clear`, they doesn't return errors
anymore, btw they (errors) were always nil :)
- Examples (master branch) were updated.
```sh
$ go get github.com/iris-contrib/sessiondb/$DATABASE
```
```go
db := $DATABASE.New(configurationHere{})
iris.UseSessionDB(db)
```
> Note: Book is not updated yet, examples are up-to-date as always.
2016-07-15 19:50:36 +02:00
|
|
|
}
|
2016-07-13 05:28:09 +02:00
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// AutoTLS can be used as an argument for the `Run` method.
|
|
|
|
// It will start the Application's secure server using
|
|
|
|
// certifications created on the fly by the "autocert" golang/x package,
|
|
|
|
// so localhost may not be working, use it at "production" machine.
|
|
|
|
//
|
2018-01-16 11:51:28 +01:00
|
|
|
// Addr should have the form of [host]:port, i.e mydomain.com:443.
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
//
|
2017-08-26 00:28:30 +02:00
|
|
|
// The whitelisted domains are separated by whitespace in "domain" argument,
|
|
|
|
// i.e "iris-go.com", can be different than "addr".
|
|
|
|
// If empty, all hosts are currently allowed. This is not recommended,
|
|
|
|
// as it opens a potential attack where clients connect to a server
|
|
|
|
// by IP address and pretend to be asking for an incorrect host name.
|
|
|
|
// Manager will attempt to obtain a certificate for that host, incorrectly,
|
|
|
|
// eventually reaching the CA's rate limit for certificate requests
|
|
|
|
// and making it impossible to obtain actual certificates.
|
|
|
|
//
|
|
|
|
// For an "e-mail" use a non-public one, letsencrypt needs that for your own security.
|
|
|
|
//
|
2018-01-16 11:51:28 +01:00
|
|
|
// Note: `AutoTLS` will start a new server for you
|
|
|
|
// which will redirect all http versions to their https, including subdomains as well.
|
2017-08-26 00:28:30 +02:00
|
|
|
//
|
|
|
|
// Last argument is optional, it accepts one or more
|
2017-07-29 03:27:58 +02:00
|
|
|
// `func(*host.Configurator)` that are being executed
|
|
|
|
// on that specific host that this function will create to start the server.
|
|
|
|
// Via host configurators you can configure the back-end host supervisor,
|
|
|
|
// i.e to add events for shutdown, serve or error.
|
|
|
|
// An example of this use case can be found at:
|
2020-06-07 14:26:06 +02:00
|
|
|
// https://github.com/kataras/iris/blob/master/_examples/http-server/notify-on-shutdown/main.go
|
2017-07-31 18:11:58 +02:00
|
|
|
// Look at the `ConfigureHost` too.
|
2017-07-29 03:27:58 +02:00
|
|
|
//
|
2017-08-26 00:28:30 +02:00
|
|
|
// Usage:
|
2018-01-16 11:51:28 +01:00
|
|
|
// app.Run(iris.AutoTLS("iris-go.com:443", "iris-go.com www.iris-go.com", "mail@example.com"))
|
2017-08-26 00:28:30 +02:00
|
|
|
//
|
|
|
|
// See `Run` and `core/host/Supervisor#ListenAndServeAutoTLS` for more.
|
|
|
|
func AutoTLS(
|
|
|
|
addr string,
|
|
|
|
domain string, email string,
|
|
|
|
hostConfigs ...host.Configurator) Runner {
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
return func(app *Application) error {
|
|
|
|
return app.NewHost(&http.Server{Addr: addr}).
|
2017-07-29 03:27:58 +02:00
|
|
|
Configure(hostConfigs...).
|
2017-08-26 00:28:30 +02:00
|
|
|
ListenAndServeAutoTLS(domain, email, "letscache")
|
2017-02-14 04:54:11 +01:00
|
|
|
}
|
2016-09-29 16:05:22 +02:00
|
|
|
}
|
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// Raw can be used as an argument for the `Run` method.
|
|
|
|
// It accepts any (listen) function that returns an error,
|
|
|
|
// this function should be block and return an error
|
|
|
|
// only when the server exited or a fatal error caused.
|
2017-02-18 07:18:09 +01:00
|
|
|
//
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// With this option you're not limited to the servers
|
2017-07-10 17:32:42 +02:00
|
|
|
// that iris can run by-default.
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
//
|
|
|
|
// See `Run` for more.
|
|
|
|
func Raw(f func() error) Runner {
|
2017-08-02 03:22:15 +02:00
|
|
|
return func(app *Application) error {
|
|
|
|
app.logger.Debugf("HTTP Server will start from unknown, external function")
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
return f()
|
2016-06-17 06:18:09 +02:00
|
|
|
}
|
2016-06-14 07:45:40 +02:00
|
|
|
}
|
|
|
|
|
2017-07-10 17:32:42 +02:00
|
|
|
// ErrServerClosed is returned by the Server's Serve, ServeTLS, ListenAndServe,
|
|
|
|
// and ListenAndServeTLS methods after a call to Shutdown or Close.
|
|
|
|
//
|
2017-07-13 15:31:36 +02:00
|
|
|
// A shortcut for the `http#ErrServerClosed`.
|
2017-07-10 17:32:42 +02:00
|
|
|
var ErrServerClosed = http.ErrServerClosed
|
|
|
|
|
2020-02-10 18:40:17 +01:00
|
|
|
// Listen builds the application and starts the server
|
|
|
|
// on the TCP network address "host:port" which
|
|
|
|
// handles requests on incoming connections.
|
|
|
|
//
|
|
|
|
// Listen always returns a non-nil error.
|
|
|
|
// Ignore specific errors by using an `iris.WithoutServerError(iris.ErrServerClosed)`
|
|
|
|
// as a second input argument.
|
|
|
|
//
|
|
|
|
// Listen is a shortcut of `app.Run(iris.Addr(hostPort, withOrWithout...))`.
|
|
|
|
// See `Run` for details.
|
|
|
|
func (app *Application) Listen(hostPort string, withOrWithout ...Configurator) error {
|
|
|
|
return app.Run(Addr(hostPort), withOrWithout...)
|
|
|
|
}
|
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// Run builds the framework and starts the desired `Runner` with or without configuration edits.
|
|
|
|
//
|
|
|
|
// Run should be called only once per Application instance, it blocks like http.Server.
|
2016-07-21 19:33:00 +02:00
|
|
|
//
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// If more than one server needed to run on the same iris instance
|
|
|
|
// then create a new host and run it manually by `go NewHost(*http.Server).Serve/ListenAndServe` etc...
|
|
|
|
// or use an already created host:
|
|
|
|
// h := NewHost(*http.Server)
|
2020-04-08 15:48:22 +02:00
|
|
|
// Run(Raw(h.ListenAndServe), WithCharset("utf-8"), WithRemoteAddrHeader("CF-Connecting-IP"))
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
//
|
|
|
|
// The Application can go online with any type of server or iris's host with the help of
|
|
|
|
// the following runners:
|
|
|
|
// `Listener`, `Server`, `Addr`, `TLS`, `AutoTLS` and `Raw`.
|
|
|
|
func (app *Application) Run(serve Runner, withOrWithout ...Configurator) error {
|
2020-05-08 02:55:54 +02:00
|
|
|
app.Configure(withOrWithout...)
|
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
if err := app.Build(); err != nil {
|
2019-10-24 17:57:05 +02:00
|
|
|
app.logger.Error(err)
|
|
|
|
return err
|
2016-06-14 07:45:40 +02:00
|
|
|
}
|
|
|
|
|
2020-06-26 19:29:36 +02:00
|
|
|
app.ConfigureHost(func(host *Supervisor) {
|
|
|
|
host.SocketSharding = app.config.SocketSharding
|
|
|
|
})
|
|
|
|
|
2019-07-17 23:53:30 +02:00
|
|
|
app.tryStartTunneling()
|
|
|
|
|
2020-04-26 05:21:20 +02:00
|
|
|
if len(app.Hosts) > 0 {
|
|
|
|
app.logger.Debugf("Application: running using %d host(s)", len(app.Hosts)+1 /* +1 the current */)
|
|
|
|
}
|
2017-08-09 16:12:24 +02:00
|
|
|
|
Publish the new version :airplane: | Look description please!
# FAQ
### Looking for free support?
http://support.iris-go.com
https://kataras.rocket.chat/channel/iris
### Looking for previous versions?
https://github.com/kataras/iris#version
### Should I upgrade my Iris?
Developers are not forced to upgrade if they don't really need it. Upgrade whenever you feel ready.
> Iris uses the [vendor directory](https://docs.google.com/document/d/1Bz5-UB7g2uPBdOx-rw5t9MxJwkfpx90cqG9AFL0JAYo) feature, so you get truly reproducible builds, as this method guards against upstream renames and deletes.
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris`.
For further installation support, please click [here](http://support.iris-go.com/d/16-how-to-install-iris-web-framework).
### About our new home page
http://iris-go.com
Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.com has been upgraded and it's really awesome!
[Santosh](https://github.com/santoshanand) is a freelancer, he has a great knowledge of nodejs and express js, Android, iOS, React Native, Vue.js etc, if you need a developer to find or create a solution for your problem or task, please contact with him.
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
Read more at https://github.com/kataras/iris/blob/master/HISTORY.md
Former-commit-id: eec2d71bbe011d6b48d2526eb25919e36e5ad94e
2017-06-03 22:22:52 +02:00
|
|
|
// this will block until an error(unless supervisor's DeferFlow called from a Task).
|
2017-07-10 17:32:42 +02:00
|
|
|
err := serve(app)
|
|
|
|
if err != nil {
|
2020-06-10 22:37:50 +02:00
|
|
|
app.logger.Error(err)
|
2016-06-06 20:04:38 +02:00
|
|
|
}
|
2017-08-02 03:22:15 +02:00
|
|
|
|
2017-07-10 17:32:42 +02:00
|
|
|
return err
|
2020-01-09 07:15:01 +01:00
|
|
|
}
|
|
|
|
|
2019-07-17 23:53:30 +02:00
|
|
|
// https://ngrok.com/docs
|
|
|
|
func (app *Application) tryStartTunneling() {
|
2020-07-10 22:21:09 +02:00
|
|
|
if len(app.config.Tunneling.Tunnels) == 0 {
|
2019-07-17 23:53:30 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
app.ConfigureHost(func(su *host.Supervisor) {
|
|
|
|
su.RegisterOnServe(func(h host.TaskHost) {
|
2020-07-10 22:21:09 +02:00
|
|
|
publicAddrs, err := tunnel.Start(app.config.Tunneling)
|
|
|
|
if err != nil {
|
|
|
|
app.logger.Errorf("Host: tunneling error: %v", err)
|
|
|
|
return
|
2019-07-17 23:53:30 +02:00
|
|
|
}
|
|
|
|
|
2020-07-10 22:21:09 +02:00
|
|
|
publicAddr := publicAddrs[0]
|
|
|
|
// to make subdomains resolution still based on this new remote, public addresses.
|
|
|
|
app.config.vhost = publicAddr[strings.Index(publicAddr, "://")+3:]
|
2019-07-17 23:53:30 +02:00
|
|
|
|
2020-07-10 22:21:09 +02:00
|
|
|
directLog := []byte(fmt.Sprintf("• Public Address: %s\n", publicAddr))
|
|
|
|
app.logger.Printer.Write(directLog) // nolint:errcheck
|
2019-07-17 23:53:30 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|