Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Support plugin only request during plugin initialization #221

Merged
merged 2 commits into from
Nov 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func main() {
Option: config.DB.Option,
DevMode: config.App.DevMode,
}
preprocessorRegistry["plugin"] = &pp.EnsurePluginReadyPreprocessor{
preprocessorRegistry["plugin_ready"] = &pp.EnsurePluginReadyPreprocessor{
PluginContext: &pluginContext,
}
preprocessorRegistry["inject_user"] = &pp.InjectUserIfPresent{}
Expand Down
2 changes: 2 additions & 0 deletions pkg/server/handler/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type AssetUploadHandler struct {
AssetStore skyAsset.Store `inject:"AssetStore"`
AccessKey router.Processor `preprocessor:"accesskey"`
DBConn router.Processor `preprocessor:"dbconn"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

Expand All @@ -44,6 +45,7 @@ func (h *AssetUploadHandler) Setup() {
h.preprocessors = []router.Processor{
h.AccessKey,
h.DBConn,
h.PluginReady,
}
}

Expand Down
8 changes: 5 additions & 3 deletions pkg/server/handler/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ type SignupHandler struct {
AccessKey router.Processor `preprocessor:"accesskey"`
DBConn router.Processor `preprocessor:"dbconn"`
InjectPublicDB router.Processor `preprocessor:"inject_public_db"`
PluginReady router.Processor `preprocessor:"plugin"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

Expand Down Expand Up @@ -225,7 +225,7 @@ type LoginHandler struct {
AccessKey router.Processor `preprocessor:"accesskey"`
DBConn router.Processor `preprocessor:"dbconn"`
InjectPublicDB router.Processor `preprocessor:"inject_public_db"`
PluginReady router.Processor `preprocessor:"plugin"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

Expand Down Expand Up @@ -345,7 +345,7 @@ func (h *LoginHandler) authPrincipal(p *loginPayload) (string, map[string]interf
type LogoutHandler struct {
TokenStore authtoken.Store `inject:"TokenStore"`
Authenticator router.Processor `preprocessor:"authenticator"`
PluginReady router.Processor `preprocessor:"plugin"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

Expand Down Expand Up @@ -432,6 +432,7 @@ type PasswordHandler struct {
DBConn router.Processor `preprocessor:"dbconn"`
InjectUser router.Processor `preprocessor:"inject_user"`
InjectDB router.Processor `preprocessor:"inject_db"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

Expand All @@ -441,6 +442,7 @@ func (h *PasswordHandler) Setup() {
h.DBConn,
h.InjectUser,
h.InjectDB,
h.PluginReady,
}
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/server/handler/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ type DeviceRegisterHandler struct {
InjectUser router.Processor `preprocessor:"inject_user"`
InjectDB router.Processor `preprocessor:"inject_db"`
RequireUser router.Processor `preprocessor:"require_user"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

Expand All @@ -98,6 +99,7 @@ func (h *DeviceRegisterHandler) Setup() {
h.InjectUser,
h.InjectDB,
h.RequireUser,
h.PluginReady,
}
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/server/handler/me.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type MeHandler struct {
Authenticator router.Processor `preprocessor:"authenticator"`
DBConn router.Processor `preprocessor:"dbconn"`
InjectUser router.Processor `preprocessor:"inject_user"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

Expand All @@ -35,6 +36,7 @@ func (h *MeHandler) Setup() {
h.Authenticator,
h.DBConn,
h.InjectUser,
h.PluginReady,
}
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/server/handler/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ type PushToUserHandler struct {
DBConn router.Processor `preprocessor:"dbconn"`
InjectDB router.Processor `preprocessor:"inject_db"`
Notification router.Processor `preprocessor:"notification"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

Expand All @@ -104,6 +105,7 @@ func (h *PushToUserHandler) Setup() {
h.DBConn,
h.InjectDB,
h.Notification,
h.PluginReady,
}
}

Expand Down Expand Up @@ -170,6 +172,7 @@ type PushToDeviceHandler struct {
DBConn router.Processor `preprocessor:"dbconn"`
InjectDB router.Processor `preprocessor:"inject_db"`
Notification router.Processor `preprocessor:"notification"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

Expand All @@ -179,6 +182,7 @@ func (h *PushToDeviceHandler) Setup() {
h.DBConn,
h.InjectDB,
h.Notification,
h.PluginReady,
}
}

Expand Down
8 changes: 6 additions & 2 deletions pkg/server/handler/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ type RecordSaveHandler struct {
InjectUser router.Processor `preprocessor:"inject_user"`
InjectDB router.Processor `preprocessor:"inject_db"`
RequireUser router.Processor `preprocessor:"require_user"`
PluginReady router.Processor `preprocessor:"plugin"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

Expand Down Expand Up @@ -410,6 +410,7 @@ type RecordFetchHandler struct {
DBConn router.Processor `preprocessor:"dbconn"`
InjectUser router.Processor `preprocessor:"inject_user"`
InjectDB router.Processor `preprocessor:"inject_db"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

Expand All @@ -419,6 +420,7 @@ func (h *RecordFetchHandler) Setup() {
h.DBConn,
h.InjectUser,
h.InjectDB,
h.PluginReady,
}
}

Expand Down Expand Up @@ -514,6 +516,7 @@ type RecordQueryHandler struct {
DBConn router.Processor `preprocessor:"dbconn"`
InjectUser router.Processor `preprocessor:"inject_user"`
InjectDB router.Processor `preprocessor:"inject_db"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

Expand All @@ -523,6 +526,7 @@ func (h *RecordQueryHandler) Setup() {
h.DBConn,
h.InjectUser,
h.InjectDB,
h.PluginReady,
}
}

Expand Down Expand Up @@ -672,7 +676,7 @@ type RecordDeleteHandler struct {
InjectUser router.Processor `preprocessor:"inject_user"`
InjectDB router.Processor `preprocessor:"inject_db"`
RequireUser router.Processor `preprocessor:"require_user"`
PluginReady router.Processor `preprocessor:"plugin"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/server/handler/relation.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ type RelationQueryHandler struct {
DBConn router.Processor `preprocessor:"dbconn"`
InjectUser router.Processor `preprocessor:"inject_user"`
InjectDB router.Processor `preprocessor:"inject_db"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

Expand All @@ -118,6 +119,7 @@ func (h *RelationQueryHandler) Setup() {
h.DBConn,
h.InjectUser,
h.InjectDB,
h.PluginReady,
}
}

Expand Down Expand Up @@ -227,6 +229,7 @@ type RelationAddHandler struct {
DBConn router.Processor `preprocessor:"dbconn"`
InjectUser router.Processor `preprocessor:"inject_user"`
InjectDB router.Processor `preprocessor:"inject_db"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

Expand All @@ -236,6 +239,7 @@ func (h *RelationAddHandler) Setup() {
h.DBConn,
h.InjectUser,
h.InjectDB,
h.PluginReady,
}
}

Expand Down Expand Up @@ -298,6 +302,7 @@ type RelationRemoveHandler struct {
DBConn router.Processor `preprocessor:"dbconn"`
InjectUser router.Processor `preprocessor:"inject_user"`
InjectDB router.Processor `preprocessor:"inject_db"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

Expand All @@ -307,6 +312,7 @@ func (h *RelationRemoveHandler) Setup() {
h.DBConn,
h.InjectUser,
h.InjectDB,
h.PluginReady,
}
}

Expand Down
8 changes: 8 additions & 0 deletions pkg/server/handler/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,19 @@ func (payload *rolePayload) Validate() skyerr.Error {
// ]
// }
type RoleDefaultHandler struct {
AccessKey router.Processor `preprocessor:"accesskey"`
DevOnly router.Processor `preprocessor:"dev_only"`
DBConn router.Processor `preprocessor:"dbconn"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

func (h *RoleDefaultHandler) Setup() {
h.preprocessors = []router.Processor{
h.AccessKey,
h.DevOnly,
h.DBConn,
h.PluginReady,
}
}

Expand Down Expand Up @@ -114,15 +118,19 @@ func (h *RoleDefaultHandler) Handle(rpayload *router.Payload, response *router.R
// ]
// }
type RoleAdminHandler struct {
AccessKey router.Processor `preprocessor:"accesskey"`
DevOnly router.Processor `preprocessor:"dev_only"`
DBConn router.Processor `preprocessor:"dbconn"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

func (h *RoleAdminHandler) Setup() {
h.preprocessors = []router.Processor{
h.AccessKey,
h.DevOnly,
h.DBConn,
h.PluginReady,
}
}

Expand Down
20 changes: 20 additions & 0 deletions pkg/server/handler/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,21 @@ EOF
*/
type SchemaRenameHandler struct {
EventSender pluginEvent.Sender `inject:"PluginEventSender"`
AccessKey router.Processor `preprocessor:"accesskey"`
DevOnly router.Processor `preprocessor:"dev_only"`
DBConn router.Processor `preprocessor:"dbconn"`
InjectDB router.Processor `preprocessor:"inject_db"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

func (h *SchemaRenameHandler) Setup() {
h.preprocessors = []router.Processor{
h.AccessKey,
h.DevOnly,
h.DBConn,
h.InjectDB,
h.PluginReady,
}
}

Expand Down Expand Up @@ -146,17 +150,21 @@ EOF
*/
type SchemaDeleteHandler struct {
EventSender pluginEvent.Sender `inject:"PluginEventSender"`
AccessKey router.Processor `preprocessor:"accesskey"`
DevOnly router.Processor `preprocessor:"dev_only"`
DBConn router.Processor `preprocessor:"dbconn"`
InjectDB router.Processor `preprocessor:"inject_db"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

func (h *SchemaDeleteHandler) Setup() {
h.preprocessors = []router.Processor{
h.AccessKey,
h.DevOnly,
h.DBConn,
h.InjectDB,
h.PluginReady,
}
}

Expand Down Expand Up @@ -248,17 +256,21 @@ EOF
*/
type SchemaCreateHandler struct {
EventSender pluginEvent.Sender `inject:"PluginEventSender"`
AccessKey router.Processor `preprocessor:"accesskey"`
DevOnly router.Processor `preprocessor:"dev_only"`
DBConn router.Processor `preprocessor:"dbconn"`
InjectDB router.Processor `preprocessor:"inject_db"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

func (h *SchemaCreateHandler) Setup() {
h.preprocessors = []router.Processor{
h.AccessKey,
h.DevOnly,
h.DBConn,
h.InjectDB,
h.PluginReady,
}
}

Expand Down Expand Up @@ -353,17 +365,21 @@ curl -X POST -H "Content-Type: application/json" \
EOF
*/
type SchemaFetchHandler struct {
AccessKey router.Processor `preprocessor:"accesskey"`
DevOnly router.Processor `preprocessor:"dev_only"`
DBConn router.Processor `preprocessor:"dbconn"`
InjectDB router.Processor `preprocessor:"inject_db"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

func (h *SchemaFetchHandler) Setup() {
h.preprocessors = []router.Processor{
h.AccessKey,
h.DevOnly,
h.DBConn,
h.InjectDB,
h.PluginReady,
}
}

Expand Down Expand Up @@ -400,9 +416,11 @@ curl -X POST -H "Content-Type: application/json" \
EOF
*/
type SchemaAccessHandler struct {
AccessKey router.Processor `preprocessor:"accesskey"`
DevOnly router.Processor `preprocessor:"dev_only"`
DBConn router.Processor `preprocessor:"dbconn"`
InjectDB router.Processor `preprocessor:"inject_db"`
PluginReady router.Processor `preprocessor:"plugin_ready"`
preprocessors []router.Processor
}

Expand All @@ -419,9 +437,11 @@ type schemaAccessResponse struct {

func (h *SchemaAccessHandler) Setup() {
h.preprocessors = []router.Processor{
h.AccessKey,
h.DevOnly,
h.DBConn,
h.InjectDB,
h.PluginReady,
}
}

Expand Down
Loading