mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 18:51:03 +01:00
serious fixes from the ago-2minutes release of the 4.0.0-alpha.3, read the HISTORY.md
**How to upgrade**: remove your `$GOPATH/src/github.com/kataras/iris` folder, open your command-line and execute this command: `go get -u github.com/kataras/iris/iris`. ## 4.0.0-alpha.2 -> 4.0.0-alpha.3 **New** A **Response Engine** gives you the freedom to create/change the render/response writer for - `context.JSON` - `context.JSONP` - `context.XML` - `context.Text` - `context.Markdown` - `context.Data` - `context.Render("my_custom_type",mystructOrData{}, iris.RenderOptions{"gzip":false,"charset":"UTF-8"})` - `context.MarkdownString` - `iris.ResponseString(...)` **Fix** - https://github.com/kataras/iris/issues/294 **Small changes** - `iris.Config.Charset`, before alpha.3 was `iris.Config.Rest.Charset` & `iris.Config.Render.Template.Charset`, but you can override it at runtime by passinth a map `iris.RenderOptions` on the `context.Render` call . - `iris.Config.IsDevelopment` , before alpha.1 was `iris.Config.Render.Template.IsDevelopment` **Websockets changes** No need to import the `github.com/kataras/iris/websocket` to use the `Connection` iteral, the websocket moved inside `kataras/iris` , now all exported variables' names have the prefix of `Websocket`, so the old `websocket.Connection` is now `iris.WebsocketConnection`. Generally, no other changes on the 'frontend API', for response engines examples and how you can register your own to add more features on existing response engines or replace them, look [here](https://github.com/iris-contrib/response). **BAD SIDE**: E-Book is still pointing on the v3 release, but will be updated soon.
This commit is contained in:
parent
675c0d510c
commit
9326a771aa
11
response.go
11
response.go
|
@ -143,8 +143,12 @@ func (r *responseEngineMap) render(ctx *Context, obj interface{}, options ...map
|
||||||
charset = chs
|
charset = chs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ctype := r.contentType
|
||||||
|
|
||||||
ctx.SetContentType(r.contentType + "; charset=" + charset)
|
if r.contentType != contentBinary { // set the charset only on non-binary data
|
||||||
|
ctype += "; charset=" + charset
|
||||||
|
}
|
||||||
|
ctx.SetContentType(ctype)
|
||||||
|
|
||||||
if gzipEnabled {
|
if gzipEnabled {
|
||||||
ctx.Response.Header.Add("Content-Encoding", "gzip")
|
ctx.Response.Header.Add("Content-Encoding", "gzip")
|
||||||
|
@ -214,7 +218,10 @@ func (r *responseEngines) add(engine ResponseEngine, forContentTypesOrKeys ...st
|
||||||
|
|
||||||
func (r *responseEngines) getBy(key string) *responseEngineMap {
|
func (r *responseEngines) getBy(key string) *responseEngineMap {
|
||||||
for i, n := 0, len(r.engines); i < n; i++ {
|
for i, n := 0, len(r.engines); i < n; i++ {
|
||||||
return r.engines[i]
|
if r.engines[i].key == key {
|
||||||
|
return r.engines[i]
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user