aboutsummaryrefslogtreecommitdiff
path: root/server.go
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2019-12-11 15:24:39 +0100
committerSimon Ser <contact@emersion.fr>2019-12-11 15:24:39 +0100
commitf07ab5263246d940fbc1d646bcdb5663398378d0 (patch)
tree3610a240635cbbac0932c359defd2962c05c3d75 /server.go
parent1b5bc568fb638314b62ea3d6635de56109680da9 (diff)
downloadalps-f07ab5263246d940fbc1d646bcdb5663398378d0.tar.gz
alps-f07ab5263246d940fbc1d646bcdb5663398378d0.zip
Add docs
Diffstat (limited to 'server.go')
-rw-r--r--server.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/server.go b/server.go
index 44392a0..1c9ca73 100644
--- a/server.go
+++ b/server.go
@@ -14,9 +14,10 @@ const cookieName = "koushin_session"
const messagesPerPage = 50
+// Server holds all the koushin server state.
type Server struct {
Sessions *SessionManager
- Plugins []Plugin
+ Plugins []Plugin
imap struct {
host string
@@ -98,11 +99,13 @@ func newServer(imapURL, smtpURL string) (*Server, error) {
type Context struct {
echo.Context
Server *Server
- Session *Session
+ Session *Session // nil if user isn't logged in
}
var aLongTimeAgo = time.Unix(233431200, 0)
+// SetSession sets a cookie for the provided session. Passing a nil session
+// unsets the cookie.
func (ctx *Context) SetSession(s *Session) {
cookie := http.Cookie{
Name: cookieName,
@@ -127,6 +130,7 @@ type Options struct {
Theme string
}
+// New creates a new server.
func New(e *echo.Echo, options *Options) error {
s, err := newServer(options.IMAPURL, options.SMTPURL)
if err != nil {