-
Notifications
You must be signed in to change notification settings - Fork 3
/
Session.go
41 lines (30 loc) · 873 Bytes
/
Session.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package HologramGo
import (
"fmt"
"os"
)
// Session implements the Session type returned from the response.
type Session map[string]interface{}
// CreateSession creates a new session.
func CreateSession(email string, password string) Session {
var params Parameters
req := createPostRequest("/auth/session", params)
resp, err := sendRequest(req)
if err != nil {
fmt.Printf("Could not send request: %v\n", err)
os.Exit(1)
}
return unmarshallIntoObject(resp)
}
// TODO: func (session Session) end // without sesskey.
// EndSession destroys a session based on the given sesskey.
func EndSession(sesskey string) Session {
var params Parameters
req := createPostRequest("/auth/sessiondestroy", params)
resp, err := sendRequest(req)
if err != nil {
fmt.Printf("Could not send request: %v\n", err)
os.Exit(1)
}
return unmarshallIntoObject(resp)
}