diff --git a/HISTORY.md b/HISTORY.md index c7f89e9b..efdc4bc7 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,6 +2,22 @@ **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.4 -> 6.0.5 + +- Add `iris.DestroySessionByID(string)` and `iris.DestroyAllSessions()` functions as requested by a community member in the [chat]https://kataras.rocket.chat/channel/iris): + +```go +// DestroySessionByID removes the session entry +// from the server-side memory (and database if registered). +// Client's session cookie will still exist but it will be reseted on the next request. +// +// It's safe to use it even if you are not sure if a session with that id exists. +DestroySessionByID(string) +// DestroyAllSessions removes all sessions +// from the server-side memory (and database if registered). +// Client's session cookie will still exist but it will be reseted on the next request. +DestroyAllSessions() +``` ## 6.0.3 -> 6.0.4 @@ -62,6 +78,8 @@ I tried to minimize the side affects. If you don't find something you used to use come here and check that conversional list: +- `iris.ToHandlerFunc` -> `iris.ToHandler` + - `context.Response.BodyWriter() io.Writer` -> `context.ResponseWriter` is a http.ResponseWriter(and io.Writer) now. - `context.RequestCtx` removed and replaced by `context.ResponseWriter (*iris.ResponseWriter -> http.ResponseWriter)` and `context.Request (*http.Request)` diff --git a/README.md b/README.md index 312033ae..dd5932a3 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@
-Releases +Releases Examples @@ -557,6 +557,9 @@ iris.Get("/products", logme, func(ctx *iris.Context) { | [OAuth,OAuth2 Plugin](https://github.com/iris-contrib/plugin/tree/master/oauth) | User Authentication was never be easier, supports >27 providers | [example](https://github.com/iris-contrib/examples/tree/master/plugin_oauth_oauth2), [book section](https://docs.iris-go.com/plugin-oauth.html) | | [Iris control Plugin](https://github.com/iris-contrib/plugin/tree/master/iriscontrol) | Basic (browser-based) control over your Iris station | [example](https://github.com/iris-contrib/examples/blob/master/plugin_iriscontrol/main.go), [book section](https://docs.iris-go.com/plugin-iriscontrol.html) | +> NOTE: All net/http handlers and middleware that already created by other go developers are also compatible with Iris, even if they are not be documented here, read more [here](https://github.com/iris-contrib/middleware#can-i-use-standard-nethttp-handler-with-iris). + + ### Sessions If you notice a bug or issue [post it here](https://github.com/kataras/go-sessions). @@ -617,6 +620,26 @@ iris.Get("/", func(ctx *iris.Context) { ``` +- `iris.DestroySessionByID(string)` + +```go +// DestroySessionByID removes the session entry +// from the server-side memory (and database if registered). +// Client's session cookie will still exist but it will be reseted on the next request. +// +// It's safe to use it even if you are not sure if a session with that id exists. +DestroySessionByID(string) +``` + +- `iris.DestroyAllSessions()` + +```go +// DestroyAllSessions removes all sessions +// from the server-side memory (and database if registered). +// Client's session cookie will still exist but it will be reseted on the next request. +DestroyAllSessions() +``` + > Each section of the README has its own - more advanced - subject on the book, so be sure to check book for any further research [Read more](https://docs.iris-go.com/package-sessions.html) @@ -823,7 +846,7 @@ I recommend writing your API tests using this new library, [httpexpect](https:// Versioning ------------ -Current: **v6.0.4** +Current: **v6.0.5** Stable: **[v5/fasthttp](https://github.com/kataras/iris/tree/5.0.0)** diff --git a/context.go b/context.go index 54588ae3..89c87b50 100644 --- a/context.go +++ b/context.go @@ -1205,7 +1205,6 @@ func (ctx *Context) SessionDestroy() { if sess := ctx.Session(); sess != nil { ctx.framework.sessions.Destroy(ctx.ResponseWriter, ctx.Request) } - } var maxAgeExp = regexp.MustCompile(`maxage=(\d+)`) diff --git a/iris.go b/iris.go index 78bbf0b9..4adb46c8 100644 --- a/iris.go +++ b/iris.go @@ -81,7 +81,7 @@ const ( // IsLongTermSupport flag is true when the below version number is a long-term-support version IsLongTermSupport = false // Version is the current version number of the Iris web framework - Version = "6.0.4" + Version = "6.0.5" banner = ` _____ _ |_ _| (_) @@ -791,6 +791,22 @@ func (s *Framework) UseSessionDB(db sessions.Database) { s.sessions.UseDatabase(db) } +// DestroySessionByID removes the session entry +// from the server-side memory (and database if registered). +// Client's session cookie will still exist but it will be reseted on the next request. +// +// It's safe to use it even if you are not sure if a session with that id exists. +func (s *Framework) DestroySessionByID(sid string) { + s.sessions.DestroyByID(sid) +} + +// DestroyAllSessions removes all sessions +// from the server-side memory (and database if registered). +// Client's session cookie will still exist but it will be reseted on the next request. +func (s *Framework) DestroyAllSessions() { + s.sessions.DestroyAll() +} + // UseSerializer accepts a Serializer and the key or content type on which the developer wants to register this serializer // the gzip and charset are automatically supported by Iris, by passing the iris.RenderOptions{} map on the context.Render // context.Render renders this response or a template engine if no response engine with the 'key' found