Skip to content

Commit

Permalink
always acquire/set/get/delete/clear/visit/release(destroy) from a dat…
Browse files Browse the repository at this point in the history
…abase if used, implement the feature request: #17
  • Loading branch information
kataras committed Apr 22, 2018
1 parent 251e425 commit 70db67d
Show file tree
Hide file tree
Showing 1,245 changed files with 5,564 additions and 421,456 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.go linguist-language=Go
vendor/* linguist-vendored
_examples/* linguist-documentation
_benchmarks/* linguist-documentation
# Set the default behavior, in case people don't have core.autocrlf set.
# if from windows:
# git config --global core.autocrlf true
Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
.project
.settings
.vscode
.vscode
/_examples/**/node_modules
24 changes: 21 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
language: go

os:
- linux
- osx
go:
- go1.8
- tip
- "go1.8"
- "go1.9"
- "go1.10"
go_import_path: github.com/kataras/go-sessions
# we disable test caching via GOCACHE=off
env:
global:
- GOCACHE=off
install:
- go get ./...
script:
- go test -v -cover ./...
after_script:
# examples
- cd ./_examples
- go get ./...
- go test -v -cover ./...
- cd ../
3 changes: 1 addition & 2 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# This is the official list of Iris Sessions authors for copyright
# purposes.

Gerasimos Maropoulos <[email protected]>
Bill Qeras, Jr. <[email protected]>
Gerasimos Maropoulos <[email protected]>
44 changes: 28 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

<a href="https://travis-ci.org/kataras/go-sessions"><img src="https://img.shields.io/travis/kataras/go-sessions.svg?style=flat-square" alt="Build Status"></a>
<a href="https://github.com/kataras/go-sessions/blob/master/LICENSE"><img src="https://img.shields.io/badge/%20license-MIT%20%20License%20-E91E63.svg?style=flat-square" alt="License"></a>
<a href="https://github.com/kataras/go-sessions/releases"><img src="https://img.shields.io/badge/%20release%20-%20v2.1.0-blue.svg?style=flat-square" alt="Releases"></a>
<a href="https://github.com/kataras/go-sessions/releases"><img src="https://img.shields.io/badge/%20release%20-%20v3.0.0-blue.svg?style=flat-square" alt="Releases"></a>
<a href="#documentation"><img src="https://img.shields.io/badge/%20docs-reference-5272B4.svg?style=flat-square" alt="Read me docs"></a>
<a href="https://kataras.rocket.chat/channel/go-sessions"><img src="https://img.shields.io/badge/%20community-chat-00BCD4.svg?style=flat-square" alt="Build Status"></a>
<a href="https://golang.org"><img src="https://img.shields.io/badge/powered_by-Go-3362c2.svg?style=flat-square" alt="Built with GoLang"></a>
<a href="#"><img src="https://img.shields.io/badge/platform-All-yellow.svg?style=flat-square" alt="Platforms"></a>
<br/>

<a href="#features" >Fast</a> http sessions manager for Go.<br/>
Simple <a href ="#outline">API</a>, while providing robust set of features such as immutability, expiration time (can be shifted), [databases](sessiondb) like badger, boltdb, raw file, leveldb and redis as back-end storage.<br/>
Simple <a href ="#outline">API</a>, while providing robust set of features such as immutability, expiration time (can be shifted), [databases](sessiondb) like badger and redis as back-end storage.<br/>

</p>

Expand Down Expand Up @@ -75,8 +75,6 @@ Take a look at the [./examples](https://github.com/kataras/go-sessions/tree/mast
- [Secure Cookie](_examples/securecookie/main.go)
- [Flash Messages](_examples/flash-messages/main.go)
- [Databases](_examples/database)
* [File](_examples/database/file/main.go)
* [BoltDB](_examples/database/boltdb/main.go)
* [Redis](_examples/database/redis/main.go)

Outline
Expand Down Expand Up @@ -127,11 +125,11 @@ UseDatabase(Database)
### Configuration

```go
// Config is the configuration for sessions. Please review it well before using sessions.
type Config struct {
// Config is the configuration for sessions. Please read it before using sessions.
Config struct {
// Cookie string, the session's client cookie name, for example: "mysessionid"
//
// Defaults to "gosessionid"
// Defaults to "irissessionid".
Cookie string

// CookieSecureTLS set to true if server is running over TLS
Expand All @@ -141,40 +139,54 @@ type Config struct {
// Recommendation: You don't need this to be setted to true, just fill the Encode and Decode fields
// with a third-party library like secure cookie, example is provided at the _examples folder.
//
// Defaults to false
// Defaults to false.
CookieSecureTLS bool

// AllowReclaim will allow to
// Destroy and Start a session in the same request handler.
// All it does is that it removes the cookie for both `Request` and `ResponseWriter` while `Destroy`
// or add a new cookie to `Request` while `Start`.
//
// Defaults to false.
AllowReclaim bool

// Encode the cookie value if not nil.
// Should accept as first argument the cookie name (config.Name)
// Should accept as first argument the cookie name (config.Cookie)
// as second argument the server's generated session id.
// Should return the new session id, if error the session id setted to empty which is invalid.
//
// Note: Errors are not printed, so you have to know what you're doing,
// and remember: if you use AES it only supports key sizes of 16, 24 or 32 bytes.
// You either need to provide exactly that amount or you derive the key from what you type in.
//
// Defaults to nil
// Defaults to nil.
Encode func(cookieName string, value interface{}) (string, error)
// Decode the cookie value if not nil.
// Should accept as first argument the cookie name (config.Name)
// Should accept as first argument the cookie name (config.Cookie)
// as second second accepts the client's cookie value (the encoded session id).
// Should return an error if decode operation failed.
//
// Note: Errors are not printed, so you have to know what you're doing,
// and remember: if you use AES it only supports key sizes of 16, 24 or 32 bytes.
// You either need to provide exactly that amount or you derive the key from what you type in.
//
// Defaults to nil
// Defaults to nil.
Decode func(cookieName string, cookieValue string, v interface{}) error

// Encoding same as Encode and Decode but receives a single instance which
// completes the "CookieEncoder" interface, `Encode` and `Decode` functions.
//
// Defaults to nil.
Encoding Encoding

// Expires the duration of which the cookie must expires (created_time.Add(Expires)).
// If you want to delete the cookie when the browser closes, set it to -1.
//
// 0 means no expire, (24 years)
// -1 means when browser closes
// > 0 is the time.Duration which the session cookies should expire.
//
// Defaults to infinitive/unlimited life duration(0)
// Defaults to infinitive/unlimited life duration(0).
Expires time.Duration

// SessionIDGenerator should returns a random session id.
Expand All @@ -184,7 +196,7 @@ type Config struct {

// DisableSubdomainPersistence set it to true in order dissallow your subdomains to have access to the session cookie
//
// Defaults to false
// Defaults to false.
DisableSubdomainPersistence bool
}
```
Expand Down Expand Up @@ -465,7 +477,7 @@ If you'd like to discuss this package, or ask questions about it, feel free to
Versioning
------------

Current: **v2.1.0**
Current: **v3.0.0**

Read more about Semantic Versioning 2.0.0

Expand Down Expand Up @@ -494,7 +506,7 @@ License can be found [here](LICENSE).
[Travis]: http://travis-ci.org/kataras/go-sessions
[License Widget]: https://img.shields.io/badge/license-MIT%20%20License%20-E91E63.svg?style=flat-square
[License]: https://github.com/kataras/go-sessions/blob/master/LICENSE
[Release Widget]: https://img.shields.io/badge/release-v2.1.0-blue.svg?style=flat-square
[Release Widget]: https://img.shields.io/badge/release-v3.0.0-blue.svg?style=flat-square
[Release]: https://github.com/kataras/go-sessions/releases
[Chat Widget]: https://img.shields.io/badge/community-chat-00BCD4.svg?style=flat-square
[Chat]: https://kataras.rocket.chat/channel/go-sessions
Expand Down
69 changes: 0 additions & 69 deletions _examples/database/boltdb/main.go

This file was deleted.

68 changes: 0 additions & 68 deletions _examples/database/file/main.go

This file was deleted.

4 changes: 3 additions & 1 deletion _examples/database/redis/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ func main() {
MaxActive: 0,
IdleTimeout: service.DefaultRedisIdleTimeout,
Prefix: "",
})
}) // to use badger just use the sessiondb/badger#New func.

defer db.Close()

sess := sessions.New(sessions.Config{Cookie: "sessionscookieid"})

Expand Down
Loading

0 comments on commit 70db67d

Please sign in to comment.