mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 17:47:03 +00:00
- Refactor datastore such that we have a FileDataStore that implements the DataStore interface. - Add in missing SMTP configuration options: max recips, max idle, max message size - Add retention options to config
34 lines
580 B
Go
34 lines
580 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.NewFileDataStore()
|
|
ctx := &Context{
|
|
Vars: vars,
|
|
Session: sess,
|
|
DataStore: ds,
|
|
}
|
|
if err != nil {
|
|
return ctx, err
|
|
}
|
|
return ctx, err
|
|
}
|