Merge pull request #15 from brunoqc/patch-1
Syntax highlighting in README.md
This commit is contained in:
commit
e89b6e26f7
38
README.md
38
README.md
|
@ -14,31 +14,33 @@ See http://www.gorillatoolkit.org/pkg/sessions for full documentation on underly
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
// Fetch new store.
|
```go
|
||||||
store := NewPGStore("postgres://user:password@127.0.0.1:5432/database?sslmode=verify-full", []byte("secret-key"))
|
// Fetch new store.
|
||||||
defer store.Close()
|
store := NewPGStore("postgres://user:password@127.0.0.1:5432/database?sslmode=verify-full", []byte("secret-key"))
|
||||||
// Run a background goroutine to clean up expired sessions from the database.
|
defer store.Close()
|
||||||
defer store.StopCleanup(store.Cleanup(time.Minute * 5))
|
// Run a background goroutine to clean up expired sessions from the database.
|
||||||
|
defer store.StopCleanup(store.Cleanup(time.Minute * 5))
|
||||||
|
|
||||||
// Get a session.
|
// Get a session.
|
||||||
session, err = store.Get(req, "session-key")
|
session, err = store.Get(req, "session-key")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err.Error())
|
log.Error(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a value.
|
// Add a value.
|
||||||
session.Values["foo"] = "bar"
|
session.Values["foo"] = "bar"
|
||||||
|
|
||||||
// Save.
|
// Save.
|
||||||
if err = sessions.Save(req, rsp); err != nil {
|
if err = sessions.Save(req, rsp); err != nil {
|
||||||
t.Fatalf("Error saving session: %v", err)
|
t.Fatalf("Error saving session: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete session.
|
// Delete session.
|
||||||
session.Options.MaxAge = -1
|
session.Options.MaxAge = -1
|
||||||
if err = sessions.Save(req, rsp); err != nil {
|
if err = sessions.Save(req, rsp); err != nil {
|
||||||
t.Fatalf("Error saving session: %v", err)
|
t.Fatalf("Error saving session: %v", err)
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Thanks
|
## Thanks
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue