mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +01:00
Add iris.DestroySessionByID(string)
and iris.DestroyAllSessions()
as requested.
This commit is contained in:
parent
7df9b2b437
commit
bcc35c11ca
18
HISTORY.md
18
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)`
|
||||
|
|
27
README.md
27
README.md
|
@ -20,7 +20,7 @@
|
|||
<br/>
|
||||
|
||||
|
||||
<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/kataras/iris/releases"><img src="https://img.shields.io/badge/%20version%20-%206.0.5%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>
|
||||
|
||||
|
@ -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)**
|
||||
|
||||
|
|
|
@ -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+)`)
|
||||
|
|
18
iris.go
18
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user