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:
Gerasimos Maropoulos 2016-07-18 18:03:43 +03:00
parent 675c0d510c
commit 9326a771aa

View File

@ -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++ {
if r.engines[i].key == key {
return r.engines[i] return r.engines[i]
} }
}
return nil return nil
} }