mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +01:00
Nothing crazy, yet. Add an iris.StaticEmbeddedHandler
shortcut of router.StaticEmbeddedHandler
and extend the configuration's tests
Former-commit-id: 7a105c12ffe08f071bff2c212f96d648ed58c542
This commit is contained in:
parent
7372cfe38d
commit
f95986d0c0
|
@ -421,7 +421,6 @@ Join the welcoming community of fellow _iris_ developers in [rocket.chat](https:
|
||||||
- :star: and watch the public [repository](https://github.com/kataras/iris/stargazers), will keep you up to date
|
- :star: and watch the public [repository](https://github.com/kataras/iris/stargazers), will keep you up to date
|
||||||
- :earth_americas: publish [an article](https://medium.com/search?q=iris) or share a [tweet](https://twitter.com/hashtag/golang) about your personal experience with iris.
|
- :earth_americas: publish [an article](https://medium.com/search?q=iris) or share a [tweet](https://twitter.com/hashtag/golang) about your personal experience with iris.
|
||||||
|
|
||||||
|
|
||||||
The most useful community repository for _iris_ developers is the
|
The most useful community repository for _iris_ developers is the
|
||||||
[iris-contrib/middleware](https://github.com/iris-contrib/middleware) which contains some HTTP handlers that can help you finish a lot of your tasks even easier. Feel free to push your own middleware there!
|
[iris-contrib/middleware](https://github.com/iris-contrib/middleware) which contains some HTTP handlers that can help you finish a lot of your tasks even easier. Feel free to push your own middleware there!
|
||||||
|
|
||||||
|
|
|
@ -110,9 +110,16 @@ EnablePathEscape: false
|
||||||
FireMethodNotAllowed: true
|
FireMethodNotAllowed: true
|
||||||
EnableOptimizations: true
|
EnableOptimizations: true
|
||||||
DisableBodyConsumptionOnUnmarshal: true
|
DisableBodyConsumptionOnUnmarshal: true
|
||||||
TimeFormat: Mon, 01 Jan 2006 15:04:05 GMT
|
TimeFormat: "Mon, 01 Jan 2006 15:04:05 GMT"
|
||||||
Charset: UTF-8
|
Charset: "UTF-8"
|
||||||
|
|
||||||
|
RemoteAddrHeaders:
|
||||||
|
X-Real-Ip: true
|
||||||
|
X-Forwarded-For: true
|
||||||
|
CF-Connecting-IP: true
|
||||||
|
|
||||||
|
Other:
|
||||||
|
MyServerName: "Iris: https://github.com/kataras/iris"
|
||||||
`
|
`
|
||||||
yamlFile.WriteString(yamlConfigurationContents)
|
yamlFile.WriteString(yamlConfigurationContents)
|
||||||
filename := yamlFile.Name()
|
filename := yamlFile.Name()
|
||||||
|
@ -151,6 +158,35 @@ Charset: UTF-8
|
||||||
if expected := "UTF-8"; c.Charset != expected {
|
if expected := "UTF-8"; c.Charset != expected {
|
||||||
t.Fatalf("error on TestConfigurationYAML: Expected Charset %s but got %s", expected, c.Charset)
|
t.Fatalf("error on TestConfigurationYAML: Expected Charset %s but got %s", expected, c.Charset)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(c.RemoteAddrHeaders) == 0 {
|
||||||
|
t.Fatalf("error on TestConfigurationYAML: Expected RemoteAddrHeaders to be filled")
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedRemoteAddrHeaders := map[string]bool{
|
||||||
|
"X-Real-Ip": true,
|
||||||
|
"X-Forwarded-For": true,
|
||||||
|
"CF-Connecting-IP": true,
|
||||||
|
}
|
||||||
|
|
||||||
|
if expected, got := len(c.RemoteAddrHeaders), len(expectedRemoteAddrHeaders); expected != got {
|
||||||
|
t.Fatalf("error on TestConfigurationYAML: Expected RemoteAddrHeaders' len(%d) and got(%d), len is not the same", expected, got)
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, v := range c.RemoteAddrHeaders {
|
||||||
|
if expected, got := expectedRemoteAddrHeaders[k], v; expected != got {
|
||||||
|
t.Fatalf("error on TestConfigurationYAML: Expected RemoteAddrHeaders[%s] = %t but got %t", k, expected, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(c.Other) == 0 {
|
||||||
|
t.Fatalf("error on TestConfigurationYAML: Expected Other to be filled")
|
||||||
|
}
|
||||||
|
|
||||||
|
if expected, got := "Iris: https://github.com/kataras/iris", c.Other["MyServerName"]; expected != got {
|
||||||
|
t.Fatalf("error on TestConfigurationYAML: Expected Other['MyServerName'] %s but got %s", expected, got)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestConfigurationTOML(t *testing.T) {
|
func TestConfigurationTOML(t *testing.T) {
|
||||||
|
@ -175,9 +211,14 @@ DisableBodyConsumptionOnUnmarshal = true
|
||||||
TimeFormat = "Mon, 01 Jan 2006 15:04:05 GMT"
|
TimeFormat = "Mon, 01 Jan 2006 15:04:05 GMT"
|
||||||
Charset = "UTF-8"
|
Charset = "UTF-8"
|
||||||
|
|
||||||
|
[RemoteAddrHeaders]
|
||||||
|
X-Real-Ip = true
|
||||||
|
X-Forwarded-For = true
|
||||||
|
CF-Connecting-IP = true
|
||||||
|
|
||||||
[Other]
|
[Other]
|
||||||
# Indentation (tabs and/or spaces) is allowed but not required
|
# Indentation (tabs and/or spaces) is allowed but not required
|
||||||
MyServerName = "Iris"
|
MyServerName = "Iris: https://github.com/kataras/iris"
|
||||||
|
|
||||||
`
|
`
|
||||||
tomlFile.WriteString(tomlConfigurationContents)
|
tomlFile.WriteString(tomlConfigurationContents)
|
||||||
|
@ -217,4 +258,32 @@ Charset = "UTF-8"
|
||||||
if expected := "UTF-8"; c.Charset != expected {
|
if expected := "UTF-8"; c.Charset != expected {
|
||||||
t.Fatalf("error on TestConfigurationTOML: Expected Charset %s but got %s", expected, c.Charset)
|
t.Fatalf("error on TestConfigurationTOML: Expected Charset %s but got %s", expected, c.Charset)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(c.RemoteAddrHeaders) == 0 {
|
||||||
|
t.Fatalf("error on TestConfigurationTOML: Expected RemoteAddrHeaders to be filled")
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedRemoteAddrHeaders := map[string]bool{
|
||||||
|
"X-Real-Ip": true,
|
||||||
|
"X-Forwarded-For": true,
|
||||||
|
"CF-Connecting-IP": true,
|
||||||
|
}
|
||||||
|
|
||||||
|
if expected, got := len(c.RemoteAddrHeaders), len(expectedRemoteAddrHeaders); expected != got {
|
||||||
|
t.Fatalf("error on TestConfigurationTOML: Expected RemoteAddrHeaders' len(%d) and got(%d), len is not the same", expected, got)
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, v := range c.RemoteAddrHeaders {
|
||||||
|
if expected, got := expectedRemoteAddrHeaders[k], v; expected != got {
|
||||||
|
t.Fatalf("error on TestConfigurationTOML: Expected RemoteAddrHeaders[%s] = %t but got %t", k, expected, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(c.Other) == 0 {
|
||||||
|
t.Fatalf("error on TestConfigurationTOML: Expected Other to be filled")
|
||||||
|
}
|
||||||
|
|
||||||
|
if expected, got := "Iris: https://github.com/kataras/iris", c.Other["MyServerName"]; expected != got {
|
||||||
|
t.Fatalf("error on TestConfigurationTOML: Expected Other['MyServerName'] %s but got %s", expected, got)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
6
iris.go
6
iris.go
|
@ -303,6 +303,12 @@ var (
|
||||||
//
|
//
|
||||||
// A shortcut for the `context#LimitRequestBodySize`.
|
// A shortcut for the `context#LimitRequestBodySize`.
|
||||||
LimitRequestBodySize = context.LimitRequestBodySize
|
LimitRequestBodySize = context.LimitRequestBodySize
|
||||||
|
// StaticEmbeddedHandler returns a Handler which can serve
|
||||||
|
// embedded into executable files.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Examples: https://github.com/kataras/iris/tree/master/_examples/file-server
|
||||||
|
StaticEmbeddedHandler = router.StaticEmbeddedHandler
|
||||||
// Gzip is a middleware which enables writing
|
// Gzip is a middleware which enables writing
|
||||||
// using gzip compression, if client supports.
|
// using gzip compression, if client supports.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue
Block a user