1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-18 18:17:03 +00:00
Files
go-inbucket/web/context.go
James Hillyerd 4e5c0ce4d8 Reorganize packages pt 1
End goal: simplify build process
2012-10-22 15:20:33 -07:00

34 lines
577 B
Go

package web
import (
"github.com/gorilla/mux"
"github.com/gorilla/sessions"
"github.com/jhillyerd/inbucket/smtpd"
"net/http"
)
type Context struct {
Vars map[string]string
Session *sessions.Session
DataStore *smtpd.DataStore
}
func (c *Context) Close() {
// Do nothing
}
func NewContext(req *http.Request) (*Context, error) {
vars := mux.Vars(req)
sess, err := sessionStore.Get(req, "inbucket")
ds := smtpd.NewDataStore()
ctx := &Context{
Vars: vars,
Session: sess,
DataStore: ds,
}
if err != nil {
return ctx, err
}
return ctx, err
}