Skip to content

Commit

Permalink
Update to version 11.0.4. Read https://github.com/kataras/iris/blob/m…
Browse files Browse the repository at this point in the history
  • Loading branch information
kataras committed Nov 9, 2018
1 parent c1ebc23 commit ba71bda
Show file tree
Hide file tree
Showing 19 changed files with 157 additions and 32 deletions.
58 changes: 58 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,64 @@ Developers are not forced to upgrade if they don't really need it. Upgrade whene
**How to upgrade**: Open your command-line and execute this command: `go get -u github.com/kataras/iris` or let the automatic updater do that for you.

# Fr, 09 November 2018 | v11.0.4

Add `Configuration.DisablePathCorrectionRedirection` - `iris.WithoutPathCorrectionRedirection` to support
direct handler execution of the matching route without the last `'/'` instead of sending a redirect response when `DisablePathCorrection` is set to false(default behavior).

Usage:

For example, CORS needs the allow origin headers in redirect response as well,
however is not possible from the router to know what headers a route's handler will send to the client.
So the best option we have is to just execute the handler itself instead of sending a redirect response.
Add the `app.Run(..., iris.WithoutPathCorrectionRedirection)` on the server side if you wish
to directly fire the handler instead of redirection (which is the default behavior)
on request paths like `"$yourdomain/v1/mailer/"` when `"/v1/mailer"` route handler is registered.

Example Code:

```go
package main

import "github.com/kataras/iris"


func main() {
app := iris.New()

crs := func(ctx iris.Context) {
ctx.Header("Access-Control-Allow-Origin", "*")
ctx.Header("Access-Control-Allow-Credentials", "true")
ctx.Header("Access-Control-Allow-Headers",
"Access-Control-Allow-Origin,Content-Type")
ctx.Next()
}

v1 := app.Party("/api/v1", crs).AllowMethods(iris.MethodOptions)
{
v1.Post("/mailer", func(ctx iris.Context) {
var any iris.Map
err := ctx.ReadJSON(&any)
if err != nil {
ctx.WriteString(err.Error())
ctx.StatusCode(iris.StatusBadRequest)
return
}
ctx.Application().Logger().Infof("received %#+v", any)
})
}

// HERE:
app.Run(iris.Addr(":80"), iris.WithoutPathCorrectionRedirection)
}
```

# Tu, 06 November 2018 | v11.0.3

- add "part" html view engine's tmpl function: [15bb55d](https://github.com/kataras/iris/commit/15bb55d85eac378bbe0c98c10ffea938cc05fe4d)

- update pug engine's vendor: [c20bc3b](https://github.com/kataras/iris/commit/c20bc3bceef158ef99931e609123fa0aca2a918c)

# Tu, 30 October 2018 | v11.0.2

Fix [memstore](core/memstore/memstore.go) overflows when build 32 bit app, reported and fixed by [@bouroo](https://github.com/bouroo) at: https://github.com/kataras/iris/issues/1118
Expand Down
4 changes: 4 additions & 0 deletions HISTORY_GR.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
**Πώς να αναβαθμίσετε**: Ανοίξτε την γραμμή εντολών σας και εκτελέστε αυτήν την εντολή: `go get -u github.com/kataras/iris` ή αφήστε το αυτόματο updater να το κάνει αυτό για σας.

# Fr, 09 November 2018 | v11.0.4

Πατήστε [εδώ](https://github.com/kataras/iris/blob/master/HISTORY.md#fr-09-november-2018--v1104) για να διαβάσετε στα αγγλικά τις αλλαγές που φέρνει το τελευταίο patch για την έκδοση 11.

# Tu, 30 October 2018 | v11.0.2

Πατήστε [εδώ](https://github.com/kataras/iris/blob/master/HISTORY.md#tu-30-october-2018--v1102) για να διαβάσετε στα αγγλικά μια σημαντική διόρθωση για τα x32 machines που φέρνει το τελευταίο patch για την έκδοση 11.
Expand Down
4 changes: 4 additions & 0 deletions HISTORY_ID.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Developers tidak diwajibkan untuk melakukan upgrade apabila mereka tidak membutu
**Cara Upgrade**: Bukan command-line anda dan eksekuis perintah ini: `go get -u github.com/kataras/iris` atau biarkan updater otomatis melakukannya untuk anda.

# Fr, 09 November 2018 | v11.0.4

This history entry is not translated yet to the Indonesian language yet, please refer to the english version of the [HISTORY entry](https://github.com/kataras/iris/blob/master/HISTORY.md#fr-09-november-2018--v1104) instead.

# Tu, 30 October 2018 | v11.0.2

This history entry is not translated yet to the Indonesian language yet, please refer to the english version of the [HISTORY entry](https://github.com/kataras/iris/blob/master/HISTORY.md#tu-30-october-2018--v1102) instead.
Expand Down
4 changes: 4 additions & 0 deletions HISTORY_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
**如何升级**: 打开命令行执行以下命令: `go get -u github.com/kataras/iris` 或者等待自动更新。

# Fr, 09 November 2018 | v11.0.4

This history entry is not translated yet to the Chinese language yet, please refer to the english version of the [HISTORY entry](https://github.com/kataras/iris/blob/master/HISTORY.md#fr-09-november-2018--v1104) instead.

# Tu, 30 October 2018 | v11.0.2

This history entry is not translated yet to the Chinese language yet, please refer to the english version of the [HISTORY entry](https://github.com/kataras/iris/blob/master/HISTORY.md#tu-30-october-2018--v1102) instead.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ Iris, unlike others, is 100% compatible with the standards and that's why the ma

## Support

- [HISTORY](HISTORY.md#tu-30-october-2018--v1102) file is your best friend, it contains information about the latest features and changes
- [HISTORY](HISTORY.md#fr-09-november-2018--v1104) file is your best friend, it contains information about the latest features and changes
- Did you happen to find a bug? Post it at [github issues](https://github.com/kataras/iris/issues)
- Do you have any questions or need to speak with someone experienced to solve a problem at real-time? Join us to the [community chat](https://chat.iris-go.com)
- Complete our form-based user experience report by clicking [here](https://docs.google.com/forms/d/e/1FAIpQLSdCxZXPANg_xHWil4kVAdhmh7EBBHQZ_4_xSZVDL-oCC_z5pA/viewform?usp=sf_link)
Expand Down
2 changes: 1 addition & 1 deletion README_GR.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ _Η τελευταία ενημέρωση έγινε την [Τρίτη, 21 Νο

## Υποστήριξη

- To [HISTORY](HISTORY_GR.md#tu-30-october-2018--v1102) αρχείο είναι ο καλύτερος σας φίλος, περιέχει πληροφορίες σχετικά με τις τελευταίες λειτουργίες(features) και αλλαγές
- To [HISTORY](HISTORY_GR.md#fr-09-november-2018--v1104) αρχείο είναι ο καλύτερος σας φίλος, περιέχει πληροφορίες σχετικά με τις τελευταίες λειτουργίες(features) και αλλαγές
- Μήπως τυχαίνει να βρήκατε κάποιο bug; Δημοσιεύστε το στα [github issues](https://github.com/kataras/iris/issues)
- Έχετε οποιεσδήποτε ερωτήσεις ή πρέπει να μιλήσετε με κάποιον έμπειρο για την επίλυση ενός προβλήματος σε πραγματικό χρόνο; Ελάτε μαζί μας στην [συνομιλία κοινότητας](https://chat.iris-go.com)
- Συμπληρώστε την αναφορά εμπειρίας χρήστη κάνοντας κλικ [εδώ](https://docs.google.com/forms/d/e/1FAIpQLSdCxZXPANg_xHWil4kVAdhmh7EBBHQZ_4_xSZVDL-oCC_z5pA/viewform?usp=sf_link)
Expand Down
2 changes: 1 addition & 1 deletion README_ID.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ _Diperbarui pada: [Tuesday, 21 November 2017](_benchmarks/README_UNIX.md)_

## Dukungan

- File [HISTORY](HISTORY_ID.md#tu-30-october-2018--v1102) adalah sahabat anda, file tersebut memiliki informasi terkait fitur dan perubahan terbaru
- File [HISTORY](HISTORY_ID.md#fr-09-november-2018--v1104) adalah sahabat anda, file tersebut memiliki informasi terkait fitur dan perubahan terbaru
- Apakah anda menemukan bug? Laporkan itu melalui [github issues](https://github.com/kataras/iris/issues)
- Apakah anda memiliki pertanyaan atau butuh untuk bicara kepada seseorang yang sudah berpengalaman untuk menyelesaikan masalah secara langsung? Gabung bersama kami di [community chat](https://chat.iris-go.com)
- Lengkapi laporan user-experience berbasis formulir kami dengan tekan [disini](https://docs.google.com/forms/d/e/1FAIpQLSdCxZXPANg_xHWil4kVAdhmh7EBBHQZ_4_xSZVDL-oCC_z5pA/viewform?usp=sf_link)
Expand Down
2 changes: 1 addition & 1 deletion README_JPN.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ _Updated at: [Tuesday, 21 November 2017](_benchmarks/README_UNIX.md)_

## 支援

- [HISTORY](HISTORY.md#tu-30-october-2018--v1102)ファイルはあなたの友人です。このファイルには、機能に関する最新の情報や変更点が記載されています。
- [HISTORY](HISTORY.md#fr-09-november-2018--v1104)ファイルはあなたの友人です。このファイルには、機能に関する最新の情報や変更点が記載されています。
- バグを発見しましたか?[github issues](https://github.com/kataras/iris/issues)に投稿をお願い致します。
- 質問がありますか?または問題を即時に解決するため、熟練者に相談する必要がありますか?[community chat](https://chat.iris-go.com)に参加しましょう。
- [here](https://docs.google.com/forms/d/e/1FAIpQLSdCxZXPANg_xHWil4kVAdhmh7EBBHQZ_4_xSZVDL-oCC_z5pA/viewform?usp=sf_link)をクリックしてユーザーとしての体験を報告しましょう。
Expand Down
2 changes: 1 addition & 1 deletion README_PT_BR.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ _Atualizado em : [Terça, 21 de Novembro de 2017](_benchmarks/README_UNIX.md)_

## Apoie

- [HISTORY](HISTORY.md#tu-30-october-2018--v1102) o arquivo HISTORY é o seu melhor amigo, ele contém informações sobre as últimas features e mudanças.
- [HISTORY](HISTORY.md#fr-09-november-2018--v1104) o arquivo HISTORY é o seu melhor amigo, ele contém informações sobre as últimas features e mudanças.
- Econtrou algum bug ? Poste-o nas [issues](https://github.com/kataras/iris/issues)
- Possui alguma dúvida ou gostaria de falar com alguém experiente para resolver seu problema em tempo real ? Junte-se ao [chat da nossa comunidade](https://chat.iris-go.com).
- Complete nosso formulário de experiência do usuário clicando [aqui](https://docs.google.com/forms/d/e/1FAIpQLSdCxZXPANg_xHWil4kVAdhmh7EBBHQZ_4_xSZVDL-oCC_z5pA/viewform?usp=sf_link)
Expand Down
2 changes: 1 addition & 1 deletion README_RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ _Обновлено: [Вторник, 21 ноября 2017 г.](_benchmarks/READ

## Поддержка

- Файл [HISTORY](HISTORY.md#tu-30-october-2018--v1102) - ваш лучший друг, он содержит информацию о последних особенностях и всех изменениях
- Файл [HISTORY](HISTORY.md#fr-09-november-2018--v1104) - ваш лучший друг, он содержит информацию о последних особенностях и всех изменениях
- Вы случайно обнаружили ошибку? Опубликуйте ее на [Github вопросы](https://github.com/kataras/iris/issues)
- У Вас есть какие-либо вопросы или Вам нужно поговорить с кем-то, кто бы смог решить Вашу проблему в режиме реального времени? Присоединяйтесь к нам в [чате сообщества](https://chat.iris-go.com)
- Заполните наш отчет о пользовательском опыте на основе формы, нажав [здесь](https://docs.google.com/forms/d/e/1FAIpQLSdCxZXPANg_xHWil4kVAdhmh7EBBHQZ_4_xSZVDL-oCC_z5pA/viewform?usp=sf_link)
Expand Down
2 changes: 1 addition & 1 deletion README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ _更新于: [2017年11月21日星期二](_benchmarks/README_UNIX.md)_

## 支持

- [更新记录](HISTORY_ZH.md#tu-30-october-2018--v1102) 是您最好的朋友,它包含有关最新功能和更改的信息
- [更新记录](HISTORY_ZH.md#fr-09-november-2018--v1104) 是您最好的朋友,它包含有关最新功能和更改的信息
- 你碰巧找到了一个错误? 请提交 [github issues](https://github.com/kataras/iris/issues)
- 您是否有任何疑问或需要与有经验的人士交谈以实时解决问题? [加入我们的聊天](https://chat.iris-go.com)
- [点击这里完成我们基于表单的用户体验报告](https://docs.google.com/forms/d/e/1FAIpQLSdCxZXPANg_xHWil4kVAdhmh7EBBHQZ_4_xSZVDL-oCC_z5pA/viewform?usp=sf_link)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11.0.2:https://github.com/kataras/iris/blob/master/HISTORY.md#tu-30-october-2018--v1102
11.0.4:https://github.com/kataras/iris/blob/master/HISTORY.md#fr-09-november-2018--v1104
8 changes: 7 additions & 1 deletion _examples/experimental-handlers/cors/simple/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,11 @@ func main() {
})
}

app.Run(iris.Addr(":80"))
// iris.WithoutPathCorrectionRedirection | iris#Configuration.DisablePathCorrectionRedirection:
// CORS needs the allow origin headers in the redirect response as well, we have a solution for this:
// If you use iris >= v11.0.4 then add the `app.Run(..., iris.WithoutPathCorrectionRedirection)`
// on the server side if you wish
// to directly fire the handler instead of redirection (which is the default behavior)
// on request paths like "/v1/mailer/" when "/v1/mailer" route handler is registered.
app.Run(iris.Addr(":80"), iris.WithoutPathCorrectionRedirection)
}
33 changes: 31 additions & 2 deletions configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,14 @@ var WithoutPathCorrection = func(app *Application) {
app.config.DisablePathCorrection = true
}

// WithoutPathCorrectionRedirection disables the PathCorrectionRedirection setting.
//
// See `Configuration`.
var WithoutPathCorrectionRedirection = func(app *Application) {
app.config.DisablePathCorrection = false
app.config.DisablePathCorrectionRedirection = true
}

// WithoutBodyConsumptionOnUnmarshal disables BodyConsumptionOnUnmarshal setting.
//
// See `Configuration`.
Expand Down Expand Up @@ -380,14 +388,24 @@ type Configuration struct {
// Defaults to false.
DisableInterruptHandler bool `json:"disableInterruptHandler,omitempty" yaml:"DisableInterruptHandler" toml:"DisableInterruptHandler"`

// DisablePathCorrection corrects and redirects the requested path to the registered path
// DisablePathCorrection corrects and redirects or executes directly the handler of
// the requested path to the registered path
// for example, if /home/ path is requested but no handler for this Route found,
// then the Router checks if /home handler exists, if yes,
// (permant)redirects the client to the correct path /home
// (permant)redirects the client to the correct path /home.
//
// See `DisablePathCorrectionRedirection` to enable direct handler execution instead of redirection.
//
// Defaults to false.
DisablePathCorrection bool `json:"disablePathCorrection,omitempty" yaml:"DisablePathCorrection" toml:"DisablePathCorrection"`

// DisablePathCorrectionRedirection works whenever configuration.DisablePathCorrection is set to false
// and if DisablePathCorrectionRedirection set to true then it will fire the handler of the matching route without
// the last slash ("/") instead of send a redirection status.
//
// Defaults to false.
DisablePathCorrectionRedirection bool `json:"disablePathCorrectionRedirection,omitempty" yaml:"DisablePathCorrectionRedirection" toml:"DisablePathCorrectionRedirection"`

// EnablePathEscape when is true then its escapes the path, the named parameters (if any).
// Change to false it if you want something like this https://github.com/kataras/iris/issues/135 to work
//
Expand Down Expand Up @@ -527,6 +545,13 @@ func (c Configuration) GetDisablePathCorrection() bool {
return c.DisablePathCorrection
}

// GetDisablePathCorrectionRedirection returns the Configuration#DisablePathCorrectionRedirection field.
// If DisablePathCorrectionRedirection set to true then it will fire the handler of the matching route without
// the last slash ("/") instead of send a redirection status.
func (c Configuration) GetDisablePathCorrectionRedirection() bool {
return c.DisablePathCorrectionRedirection
}

// GetEnablePathEscape is the Configuration#EnablePathEscape,
// returns true when its escapes the path, the named parameters (if any).
func (c Configuration) GetEnablePathEscape() bool {
Expand Down Expand Up @@ -668,6 +693,10 @@ func WithConfiguration(c Configuration) Configurator {
main.DisablePathCorrection = v
}

if v := c.DisablePathCorrectionRedirection; v {
main.DisablePathCorrectionRedirection = v
}

if v := c.EnablePathEscape; v {
main.EnablePathEscape = v
}
Expand Down
10 changes: 10 additions & 0 deletions configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ func TestConfigurationYAML(t *testing.T) {

yamlConfigurationContents := `
DisablePathCorrection: false
DisablePathCorrectionRedirection: true
EnablePathEscape: false
FireMethodNotAllowed: true
EnableOptimizations: true
Expand All @@ -167,6 +168,10 @@ Other:
t.Fatalf("error on TestConfigurationYAML: Expected DisablePathCorrection %v but got %v", expected, c.DisablePathCorrection)
}

if expected := true; c.DisablePathCorrectionRedirection != expected {
t.Fatalf("error on TestConfigurationYAML: Expected DisablePathCorrectionRedirection %v but got %v", expected, c.DisablePathCorrectionRedirection)
}

if expected := false; c.EnablePathEscape != expected {
t.Fatalf("error on TestConfigurationYAML: Expected EnablePathEscape %v but got %v", expected, c.EnablePathEscape)
}
Expand Down Expand Up @@ -235,6 +240,7 @@ func TestConfigurationTOML(t *testing.T) {
}()

tomlConfigurationContents := `
DisablePathCorrectionRedirection = true
EnablePathEscape = false
FireMethodNotAllowed = true
EnableOptimizations = true
Expand Down Expand Up @@ -262,6 +268,10 @@ Charset = "UTF-8"
t.Fatalf("error on TestConfigurationTOML: Expected DisablePathCorrection %v but got %v", expected, c.DisablePathCorrection)
}

if expected := true; c.DisablePathCorrectionRedirection != expected {
t.Fatalf("error on TestConfigurationTOML: Expected DisablePathCorrectionRedirection %v but got %v", expected, c.DisablePathCorrectionRedirection)
}

if expected := false; c.EnablePathEscape != expected {
t.Fatalf("error on TestConfigurationTOML: Expected EnablePathEscape %v but got %v", expected, c.EnablePathEscape)
}
Expand Down
5 changes: 5 additions & 0 deletions context/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ type ConfigurationReadOnly interface {
// (permant)redirects the client to the correct path /home.
GetDisablePathCorrection() bool

// GetDisablePathCorrectionRedirection returns the Configuration#DisablePathCorrectionRedirection field.
// If DisablePathCorrectionRedirection set to true then it will fire the handler of the matching route without
// the last slash ("/") instead of send a redirection status.
GetDisablePathCorrectionRedirection() bool

// GetEnablePathEscape is the configuration.EnablePathEscape,
// returns true when its escapes the path, the named parameters (if any).
GetEnablePathEscape() bool
Expand Down
Loading

0 comments on commit ba71bda

Please sign in to comment.