From 7600adb37311ca7646a3355557fc0286db2b81db Mon Sep 17 00:00:00 2001 From: Vilsol Date: Sun, 28 Oct 2018 22:16:49 +0200 Subject: [PATCH] Add middleware meta --- plugins/types.go | 4 ++-- schema/types.go | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/types.go b/plugins/types.go index fd949f7..20c36c8 100644 --- a/plugins/types.go +++ b/plugins/types.go @@ -77,12 +77,12 @@ type Middleware interface { // Validate request // If returns nil, it will pass the request onwards // If returns a pointer, request will get replied to with provided response - Request(resource string, headers map[string][]string) *middleware.RequestResponse + Request(resource string, headers map[string][]string, config interface{}) *middleware.RequestResponse // Validate and filter response // If returns nil, it will pass the request onwards with the returned data // If returns a pointer, request will get replied to with provided response without data - Response(resource string, headers map[string][]string, data []map[string]interface{}) ([]map[string]interface{}, *middleware.RequestResponse) + Response(resource string, headers map[string][]string, data []map[string]interface{}, config interface{}) ([]map[string]interface{}, *middleware.RequestResponse) } type Registry interface { diff --git a/schema/types.go b/schema/types.go index af01cff..cd2f905 100644 --- a/schema/types.go +++ b/schema/types.go @@ -19,7 +19,13 @@ type Schema struct { Meta ResourceMeta } +type MiddlewareMeta struct { + Type string `json:"type"` + Data interface{} `json:"data"` +} + type ResourceMeta struct { - Resource string `json:"resource"` - Store string `json:"store"` + Resource string `json:"resource"` + Store string `json:"store"` + Middlewares []MiddlewareMeta `json:"middlewares"` }