summaryrefslogtreecommitdiff
path: root/vendor/github.com/quasoft/memstore/README.md
diff options
context:
space:
mode:
authorLibravatar Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com>2021-08-12 21:03:24 +0200
committerLibravatar GitHub <noreply@github.com>2021-08-12 21:03:24 +0200
commit98263a7de64269898a2f81207e38943b5c8e8653 (patch)
tree743c90f109a6c5d27832d1dcef2388d939f0f77a /vendor/github.com/quasoft/memstore/README.md
parentText duplication fix (#137) (diff)
downloadgotosocial-98263a7de64269898a2f81207e38943b5c8e8653.tar.xz
Grand test fixup (#138)
* start fixing up tests * fix up tests + automate with drone * fiddle with linting * messing about with drone.yml * some more fiddling * hmmm * add cache * add vendor directory * verbose * ci updates * update some little things * update sig
Diffstat (limited to 'vendor/github.com/quasoft/memstore/README.md')
-rw-r--r--vendor/github.com/quasoft/memstore/README.md74
1 files changed, 74 insertions, 0 deletions
diff --git a/vendor/github.com/quasoft/memstore/README.md b/vendor/github.com/quasoft/memstore/README.md
new file mode 100644
index 000000000..474aa6f1f
--- /dev/null
+++ b/vendor/github.com/quasoft/memstore/README.md
@@ -0,0 +1,74 @@
+# memstore
+
+[![GoDoc](https://godoc.org/github.com/quasoft/memstore?status.svg)](https://godoc.org/github.com/quasoft/memstore) [![Build Status](https://travis-ci.org/quasoft/memstore.png?branch=master)](https://travis-ci.org/quasoft/memstore) [![Coverage Status](https://coveralls.io/repos/github/quasoft/memstore/badge.svg?branch=master)](https://coveralls.io/github/quasoft/memstore?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/quasoft/memstore)](https://goreportcard.com/report/github.com/quasoft/memstore)
+
+In-memory implementation of [gorilla/sessions](https://github.com/gorilla/sessions) for use in tests and dev environments
+
+## How to install
+
+ go get github.com/quasoft/memstore
+
+## Documentation
+
+Documentation, as usual, can be found at [godoc.org](http://www.godoc.org/github.com/quasoft/memstore).
+
+The interface of [gorilla/sessions](https://github.com/gorilla/sessions) is described at http://www.gorillatoolkit.org/pkg/sessions.
+
+### How to use
+``` go
+package main
+
+import (
+ "fmt"
+ "log"
+ "net/http"
+
+ "github.com/quasoft/memstore"
+)
+
+func main() {
+ // Create a memory store, providing authentication and
+ // encryption key for securecookie
+ store := memstore.NewMemStore(
+ []byte("authkey123"),
+ []byte("enckey12341234567890123456789012"),
+ )
+
+ http.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) {
+ // Get session by name.
+ session, err := store.Get(r, "session1")
+ if err != nil {
+ log.Printf("Error retrieving session: %v", err)
+ }
+
+ // The name should be 'foobar' if home page was visited before that and 'Guest' otherwise.
+ user, ok := session.Values["username"]
+ if !ok {
+ user = "Guest"
+ }
+ fmt.Fprintf(w, "Hello %s", user)
+ })
+
+ http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
+ // Get session by name.
+ session, err := store.Get(r, "session1")
+ if err != nil {
+ log.Printf("Error retrieving session: %v", err)
+ }
+
+ // Add values to the session object
+ session.Values["username"] = "foobar"
+ session.Values["email"] = "spam@eggs.com"
+
+ // Save values
+ err = session.Save(r, w)
+ if err != nil {
+ log.Fatalf("Error saving session: %v", err)
+ }
+ })
+
+ log.Printf("listening on http://%s/", "127.0.0.1:9090")
+ log.Fatal(http.ListenAndServe("127.0.0.1:9090", nil))
+}
+
+```