1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-19 09:50:52 +00:00

Add CollectionFormatter

This commit is contained in:
Darren Shepherd
2018-01-19 23:25:36 -07:00
committed by Craig Jellick
parent 69d780d557
commit d170661103
3 changed files with 20 additions and 12 deletions

View File

@@ -80,6 +80,11 @@ func (j *JSONResponseWriter) writeInterfaceSlice(builder *builder.Builder, apiCo
collection.Data = append(collection.Data, v) collection.Data = append(collection.Data, v)
} }
} }
if apiContext.Schema.CollectionFormatter != nil {
apiContext.Schema.CollectionFormatter(apiContext, collection)
}
return collection return collection
} }

View File

@@ -55,6 +55,8 @@ type Validator func(request *APIContext, schema *Schema, data map[string]interfa
type Formatter func(request *APIContext, resource *RawResource) type Formatter func(request *APIContext, resource *RawResource)
type CollectionFormatter func(request *APIContext, collection *GenericCollection)
type ErrorHandler func(request *APIContext, err error) type ErrorHandler func(request *APIContext, err error)
type SubContextAttributeProvider interface { type SubContextAttributeProvider interface {

View File

@@ -112,6 +112,7 @@ type Schema struct {
DeleteHandler RequestHandler `json:"-"` DeleteHandler RequestHandler `json:"-"`
UpdateHandler RequestHandler `json:"-"` UpdateHandler RequestHandler `json:"-"`
Formatter Formatter `json:"-"` Formatter Formatter `json:"-"`
CollectionFormatter CollectionFormatter `json:"-"`
ErrorHandler ErrorHandler `json:"-"` ErrorHandler ErrorHandler `json:"-"`
Validator Validator `json:"-"` Validator Validator `json:"-"`
Store Store `json:"-"` Store Store `json:"-"`