From f07ab5263246d940fbc1d646bcdb5663398378d0 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 11 Dec 2019 15:24:39 +0100 Subject: Add docs --- server.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'server.go') 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 { -- cgit v1.2.3