mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +01:00
Update to 4.5.1
This commit is contained in:
parent
f46452a7ab
commit
40b000c20f
|
@ -2,6 +2,12 @@
|
|||
|
||||
**How to upgrade**: remove your `$GOPATH/src/github.com/kataras` folder, open your command-line and execute this command: `go get -u github.com/kataras/iris/iris`.
|
||||
|
||||
## 4.5.0 -> 4.5.1
|
||||
|
||||
- **NEW**: `PreBuild` plugin type, raises before `.Build`. Used by third-party plugins to register any runtime routes or make any changes to the iris main configuration, example of this usage is the [OAuth/OAuth2 Plugin](https://github.com/iris-contrib/plugin/tree/master/oauth).
|
||||
|
||||
- **FIX**: The [OAuth example](https://github.com/iris-contrib/examples/tree/master/plugin_oauth_oauth2).
|
||||
|
||||
## 4.4.9 -> 4.5.0
|
||||
|
||||
- **NEW**: Websocket configuration fields:
|
||||
|
@ -9,7 +15,7 @@
|
|||
- `CheckOrigin func(ctx *Context)`. Manually allow or dissalow client's websocket access, ex: via header **Origin**. Default allow all origins(CORS-like) as before.
|
||||
- `Headers bool`. Allow websocket handler to copy request's headers on the handshake. Default is true
|
||||
With these in-mind the `WebsocketConfiguration` seems like this now :
|
||||
|
||||
|
||||
```go
|
||||
type WebsocketConfiguration struct {
|
||||
// WriteTimeout time allowed to write a message to the connection.
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<br/>
|
||||
|
||||
|
||||
<a href="https://github.com/kataras/iris/releases"><img src="https://img.shields.io/badge/%20version%20-%204.5.0%20-blue.svg?style=flat-square" alt="Releases"></a>
|
||||
<a href="https://github.com/kataras/iris/releases"><img src="https://img.shields.io/badge/%20version%20-%204.5.1%20-blue.svg?style=flat-square" alt="Releases"></a>
|
||||
|
||||
<a href="https://github.com/iris-contrib/examples"><img src="https://img.shields.io/badge/%20examples-repository-3362c2.svg?style=flat-square" alt="Examples"></a>
|
||||
|
||||
|
@ -871,7 +871,7 @@ I recommend writing your API tests using this new library, [httpexpect](https://
|
|||
Versioning
|
||||
------------
|
||||
|
||||
Current: **v4.5.0**
|
||||
Current: **v4.5.1**
|
||||
|
||||
> Iris is an active project
|
||||
|
||||
|
@ -907,7 +907,7 @@ This project is licensed under the [MIT License](LICENSE), Copyright (c) 2016 Ge
|
|||
[Travis]: http://travis-ci.org/kataras/iris
|
||||
[License Widget]: https://img.shields.io/badge/license-MIT%20%20License%20-E91E63.svg?style=flat-square
|
||||
[License]: https://github.com/kataras/iris/blob/master/LICENSE
|
||||
[Release Widget]: https://img.shields.io/badge/release-4.5.0%20-blue.svg?style=flat-square
|
||||
[Release Widget]: https://img.shields.io/badge/release-4.5.1%20-blue.svg?style=flat-square
|
||||
[Release]: https://github.com/kataras/iris/releases
|
||||
[Chat Widget]: https://img.shields.io/badge/community-chat%20-00BCD4.svg?style=flat-square
|
||||
[Chat]: https://kataras.rocket.chat/channel/iris
|
||||
|
|
39
iris.go
39
iris.go
|
@ -79,7 +79,7 @@ import (
|
|||
|
||||
const (
|
||||
// Version is the current version of the Iris web framework
|
||||
Version = "4.5.0"
|
||||
Version = "4.5.1"
|
||||
|
||||
banner = ` _____ _
|
||||
|_ _| (_)
|
||||
|
@ -299,6 +299,25 @@ func Build() {
|
|||
// SERVE IRIS BEHIND AN EXTERNAL CUSTOM fasthttp.Server, CAN BE CALLED ONCE PER IRIS INSTANCE FOR YOUR SAFETY
|
||||
func (s *Framework) Build() {
|
||||
s.once.Do(func() {
|
||||
// .Build, normally*, auto-called after station's listener setted but before the real Serve, so here set the host, scheme
|
||||
// and the mux hostname(*this is here because user may not call .Serve/.Listen functions if listen by a custom server)
|
||||
|
||||
if s.Config.VHost == "" { // if not setted by Listen functions
|
||||
if s.ln != nil { // but user called .Serve
|
||||
// then take the listener's addr
|
||||
s.Config.VHost = s.ln.Addr().String()
|
||||
} else {
|
||||
// if no .Serve or .Listen called, then the user should set the VHost manually,
|
||||
// however set it to a default value here for any case
|
||||
s.Config.VHost = DefaultServerAddr
|
||||
}
|
||||
}
|
||||
// if user didn't specified a scheme then get it from the VHost, which is already setted at before statements
|
||||
if s.Config.VScheme == "" {
|
||||
s.Config.VScheme = ParseScheme(s.Config.VHost)
|
||||
}
|
||||
|
||||
s.Plugins.DoPreBuild(s) // once after configuration has been setted. *nothing stops you to change the VHost and VScheme at this point*
|
||||
// re-nwe logger's attrs
|
||||
s.Logger.SetPrefix(s.Config.LoggerPreffix)
|
||||
s.Logger.SetOutput(s.Config.LoggerOut)
|
||||
|
@ -350,24 +369,6 @@ func (s *Framework) Build() {
|
|||
s.Router = defaultHandler
|
||||
}
|
||||
|
||||
// .Build, normally*, auto-called after station's listener setted but before the real Serve, so here set the host, scheme
|
||||
// and the mux hostname(*this is here because user may not call .Serve/.Listen functions if listen by a custom server)
|
||||
|
||||
if s.Config.VHost == "" { // if not setted by Listen functions
|
||||
if s.ln != nil { // but user called .Serve
|
||||
// then take the listener's addr
|
||||
s.Config.VHost = s.ln.Addr().String()
|
||||
} else {
|
||||
// if no .Serve or .Listen called, then the user should set the VHost manually,
|
||||
// however set it to a default value here for any case
|
||||
s.Config.VHost = DefaultServerAddr
|
||||
}
|
||||
}
|
||||
// if user didn't specified a scheme then get it from the VHost, which is already setted at before statements
|
||||
if s.Config.VScheme == "" {
|
||||
s.Config.VScheme = ParseScheme(s.Config.VHost)
|
||||
}
|
||||
|
||||
// set the mux' hostname (for multi subdomain routing)
|
||||
s.mux.hostname = ParseHostname(s.Config.VHost)
|
||||
|
||||
|
|
39
plugin.go
39
plugin.go
|
@ -60,11 +60,22 @@ type (
|
|||
}
|
||||
// PreLookupFunc implements the simple function listener for the PreLookup(Route)
|
||||
PreLookupFunc func(Route)
|
||||
// pluginPreBuild implements the PreBuild(*Framework) method
|
||||
pluginPreBuild interface {
|
||||
// PreBuild it's being called once time, BEFORE the Server is started and before PreListen
|
||||
// is used to do work before all other things are ready
|
||||
// use this event if you want to add routes to your iris station
|
||||
// or make any changes to the iris main configuration
|
||||
// receiver is the station
|
||||
PreBuild(*Framework)
|
||||
}
|
||||
// PreBuildFunc implements the simple function listener for the PreBuild(*Framework)
|
||||
PreBuildFunc func(*Framework)
|
||||
// pluginPreListen implements the PreListen(*Framework) method
|
||||
pluginPreListen interface {
|
||||
// PreListen it's being called only one time, BEFORE the Server is started (if .Listen called)
|
||||
// is used to do work at the time all other things are ready to go
|
||||
// parameter is the station
|
||||
// receiver is the station
|
||||
PreListen(*Framework)
|
||||
}
|
||||
// PreListenFunc implements the simple function listener for the PreListen(*Framework)
|
||||
|
@ -114,6 +125,8 @@ type (
|
|||
Printf(string, ...interface{})
|
||||
PreLookup(PreLookupFunc)
|
||||
DoPreLookup(Route)
|
||||
PreBuild(PreBuildFunc)
|
||||
DoPreBuild(*Framework)
|
||||
PreListen(PreListenFunc)
|
||||
DoPreListen(*Framework)
|
||||
DoPreListenParallel(*Framework)
|
||||
|
@ -159,6 +172,15 @@ func (fn PreLookupFunc) PreLookup(r Route) {
|
|||
fn(r)
|
||||
}
|
||||
|
||||
// PreBuild it's being called once time, BEFORE the Server is started and before PreListen
|
||||
// is used to do work before all other things are ready
|
||||
// use this event if you want to add routes to your iris station
|
||||
// or make any changes to the iris main configuration
|
||||
// receiver is the station
|
||||
func (fn PreBuildFunc) PreBuild(station *Framework) {
|
||||
fn(station)
|
||||
}
|
||||
|
||||
// PreListen it's being called only one time, BEFORE the Server is started (if .Listen called)
|
||||
// is used to do work at the time all other things are ready to go
|
||||
// parameter is the station
|
||||
|
@ -371,6 +393,21 @@ func (p *pluginContainer) DoPreLookup(r Route) {
|
|||
}
|
||||
}
|
||||
|
||||
// PreBuild adds a PreBuild plugin-function to the plugin flow container
|
||||
func (p *pluginContainer) PreBuild(fn PreBuildFunc) {
|
||||
p.Add(fn)
|
||||
}
|
||||
|
||||
// DoPreBuild raise all plugins that have the PreBuild method
|
||||
func (p *pluginContainer) DoPreBuild(station *Framework) {
|
||||
for i := range p.activatedPlugins {
|
||||
// check if this method exists on our plugin obj, these are optionaly and call it
|
||||
if pluginObj, ok := p.activatedPlugins[i].(pluginPreBuild); ok {
|
||||
pluginObj.PreBuild(station)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PreListen adds a PreListen plugin-function to the plugin flow container
|
||||
func (p *pluginContainer) PreListen(fn PreListenFunc) {
|
||||
p.Add(fn)
|
||||
|
|
Loading…
Reference in New Issue
Block a user