mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +01:00
This commit is contained in:
parent
d5a9410e2a
commit
d060a73559
|
@ -2,6 +2,13 @@
|
||||||
|
|
||||||
**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`.
|
**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`.
|
||||||
|
|
||||||
|
|
||||||
|
## 6.0.3 -> 6.0.4
|
||||||
|
|
||||||
|
- Add a simple `context.StreamWriter` to fill the v5's StreamWriter, it's a `io.Writer` instead of `bufio.Writer` and returns false when stop otherwise true. Take a look at the silly book examples [here](https://docs.iris-go.com/streaming).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 6.0.2 -> 6.0.3
|
## 6.0.2 -> 6.0.3
|
||||||
|
|
||||||
- Give the users an easy to way to set a limit to the body size comes from the client, globally or per-route (useful when you want to disable/enable limit on certain clients).
|
- Give the users an easy to way to set a limit to the body size comes from the client, globally or per-route (useful when you want to disable/enable limit on certain clients).
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
<a href="https://github.com/kataras/iris/releases"><img src="https://img.shields.io/badge/%20version%20-%206.0.3%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-%206.0.4%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>
|
<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>
|
||||||
|
|
||||||
|
@ -823,7 +823,7 @@ I recommend writing your API tests using this new library, [httpexpect](https://
|
||||||
Versioning
|
Versioning
|
||||||
------------
|
------------
|
||||||
|
|
||||||
Current: **v6.0.3**
|
Current: **v6.0.4**
|
||||||
|
|
||||||
Stable: **[v5/fasthttp](https://github.com/kataras/iris/tree/5.0.0)**
|
Stable: **[v5/fasthttp](https://github.com/kataras/iris/tree/5.0.0)**
|
||||||
|
|
||||||
|
|
52
context.go
52
context.go
|
@ -68,15 +68,6 @@ const (
|
||||||
stopExecutionPosition = 255
|
stopExecutionPosition = 255
|
||||||
)
|
)
|
||||||
|
|
||||||
// errors
|
|
||||||
|
|
||||||
var (
|
|
||||||
errTemplateExecute = errors.New("Unable to execute a template. Trace: %s")
|
|
||||||
errFlashNotFound = errors.New("Unable to get flash message. Trace: Cookie does not exists")
|
|
||||||
errReadBody = errors.New("While trying to read %s from the request body. Trace %s")
|
|
||||||
errServeContent = errors.New("While trying to serve content to the client. Trace %s")
|
|
||||||
)
|
|
||||||
|
|
||||||
type (
|
type (
|
||||||
requestValue struct {
|
requestValue struct {
|
||||||
key []byte
|
key []byte
|
||||||
|
@ -384,6 +375,12 @@ func (ctx *Context) FormFile(key string) (multipart.File, *multipart.FileHeader,
|
||||||
return ctx.Request.FormFile(key)
|
return ctx.Request.FormFile(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
errTemplateExecute = errors.New("Unable to execute a template. Trace: %s")
|
||||||
|
errReadBody = errors.New("While trying to read %s from the request body. Trace %s")
|
||||||
|
errServeContent = errors.New("While trying to serve content to the client. Trace %s")
|
||||||
|
)
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
// -----------------------------Request Body Binders/Readers----------------------------
|
// -----------------------------Request Body Binders/Readers----------------------------
|
||||||
|
@ -515,10 +512,6 @@ func (ctx *Context) SetStatusCode(statusCode int) {
|
||||||
ctx.ResponseWriter.WriteHeader(statusCode)
|
ctx.ResponseWriter.WriteHeader(statusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
// it used only inside Redirect,
|
|
||||||
// keep it here for allocations reason
|
|
||||||
var httpsSchemeOnlyBytes = []byte("https")
|
|
||||||
|
|
||||||
// Redirect redirect sends a redirect response the client
|
// Redirect redirect sends a redirect response the client
|
||||||
// accepts 2 parameters string and an optional int
|
// accepts 2 parameters string and an optional int
|
||||||
// first parameter is the url to redirect
|
// first parameter is the url to redirect
|
||||||
|
@ -608,6 +601,7 @@ func (ctx *Context) WriteGzip(b []byte) (int, error) {
|
||||||
} // else write the contents as it is? no let's create a new func for this
|
} // else write the contents as it is? no let's create a new func for this
|
||||||
return n, err
|
return n, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0, errClientDoesNotSupportGzip
|
return 0, errClientDoesNotSupportGzip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -870,6 +864,38 @@ func (ctx *Context) SendFile(filename string, destinationName string) {
|
||||||
ctx.ResponseWriter.Header().Set(contentDisposition, "attachment;filename="+destinationName)
|
ctx.ResponseWriter.Header().Set(contentDisposition, "attachment;filename="+destinationName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StreamWriter registers the given stream writer for populating
|
||||||
|
// response body.
|
||||||
|
//
|
||||||
|
// Access to context's and/or its' members is forbidden from writer.
|
||||||
|
//
|
||||||
|
// This function may be used in the following cases:
|
||||||
|
//
|
||||||
|
// * if response body is too big (more than iris.LimitRequestBodySize(if setted)).
|
||||||
|
// * if response body is streamed from slow external sources.
|
||||||
|
// * if response body must be streamed to the client in chunks.
|
||||||
|
// (aka `http server push`).
|
||||||
|
//
|
||||||
|
// receives a function which receives the response writer
|
||||||
|
// and returns false when it should stop writing, otherwise true in order to continue
|
||||||
|
func (ctx *Context) StreamWriter(writer func(w io.Writer) bool) {
|
||||||
|
w := ctx.ResponseWriter
|
||||||
|
notifyClosed := w.CloseNotify()
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
// response writer forced to close, exit.
|
||||||
|
case <-notifyClosed:
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
shouldContinue := writer(w)
|
||||||
|
w.Flush()
|
||||||
|
if !shouldContinue {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
// -------------------------------------------------------------------------------------
|
// -------------------------------------------------------------------------------------
|
||||||
// --------------------------------Storage----------------------------------------------
|
// --------------------------------Storage----------------------------------------------
|
||||||
|
|
2
iris.go
2
iris.go
|
@ -81,7 +81,7 @@ const (
|
||||||
// IsLongTermSupport flag is true when the below version number is a long-term-support version
|
// IsLongTermSupport flag is true when the below version number is a long-term-support version
|
||||||
IsLongTermSupport = false
|
IsLongTermSupport = false
|
||||||
// Version is the current version number of the Iris web framework
|
// Version is the current version number of the Iris web framework
|
||||||
Version = "6.0.3"
|
Version = "6.0.4"
|
||||||
|
|
||||||
banner = ` _____ _
|
banner = ` _____ _
|
||||||
|_ _| (_)
|
|_ _| (_)
|
||||||
|
|
|
@ -157,6 +157,7 @@ func (w *ResponseRecorder) flushResponse() {
|
||||||
func (w *ResponseRecorder) Flush() {
|
func (w *ResponseRecorder) Flush() {
|
||||||
w.flushResponse()
|
w.flushResponse()
|
||||||
w.responseWriter.Flush()
|
w.responseWriter.Flush()
|
||||||
|
w.ResetBody()
|
||||||
}
|
}
|
||||||
|
|
||||||
// clone returns a clone of this response writer
|
// clone returns a clone of this response writer
|
||||||
|
|
Loading…
Reference in New Issue
Block a user