mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 17:47:03 +00:00
message: Implement service layer, stubs for #81
I've made some effort to wire the manager into the controllers, but tests are currently failing.
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/gorilla/sessions"
|
||||
"github.com/jhillyerd/inbucket/pkg/config"
|
||||
"github.com/jhillyerd/inbucket/pkg/message"
|
||||
"github.com/jhillyerd/inbucket/pkg/msghub"
|
||||
"github.com/jhillyerd/inbucket/pkg/storage"
|
||||
)
|
||||
@@ -17,6 +18,7 @@ type Context struct {
|
||||
Session *sessions.Session
|
||||
DataStore storage.Store
|
||||
MsgHub *msghub.Hub
|
||||
MsgSvc message.Manager
|
||||
WebConfig config.WebConfig
|
||||
IsJSON bool
|
||||
}
|
||||
@@ -61,6 +63,7 @@ func NewContext(req *http.Request) (*Context, error) {
|
||||
Session: sess,
|
||||
DataStore: DataStore,
|
||||
MsgHub: msgHub,
|
||||
MsgSvc: msgSvc,
|
||||
WebConfig: webConfig,
|
||||
IsJSON: headerMatch(req, "Accept", "application/json"),
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/gorilla/sessions"
|
||||
"github.com/jhillyerd/inbucket/pkg/config"
|
||||
"github.com/jhillyerd/inbucket/pkg/log"
|
||||
"github.com/jhillyerd/inbucket/pkg/message"
|
||||
"github.com/jhillyerd/inbucket/pkg/msghub"
|
||||
"github.com/jhillyerd/inbucket/pkg/storage"
|
||||
)
|
||||
@@ -27,6 +28,7 @@ var (
|
||||
|
||||
// msgHub holds a reference to the message pub/sub system
|
||||
msgHub *msghub.Hub
|
||||
msgSvc message.Manager
|
||||
|
||||
// Router is shared between httpd, webui and rest packages. It sends
|
||||
// incoming requests to the correct handler function
|
||||
@@ -51,6 +53,7 @@ func init() {
|
||||
func Initialize(
|
||||
cfg config.WebConfig,
|
||||
shutdownChan chan bool,
|
||||
mm message.Manager,
|
||||
ds storage.Store,
|
||||
mh *msghub.Hub) {
|
||||
|
||||
@@ -60,6 +63,7 @@ func Initialize(
|
||||
// NewContext() will use this DataStore for the web handlers
|
||||
DataStore = ds
|
||||
msgHub = mh
|
||||
msgSvc = mm
|
||||
|
||||
// Content Paths
|
||||
log.Infof("HTTP templates mapped to %q", cfg.TemplateDir)
|
||||
|
||||
Reference in New Issue
Block a user