mirror of
https://github.com/rancher/norman.git
synced 2025-09-19 01:17:04 +00:00
Add CollectionFormatter
This commit is contained in:
committed by
Craig Jellick
parent
69d780d557
commit
d170661103
@@ -80,6 +80,11 @@ func (j *JSONResponseWriter) writeInterfaceSlice(builder *builder.Builder, apiCo
|
||||
collection.Data = append(collection.Data, v)
|
||||
}
|
||||
}
|
||||
|
||||
if apiContext.Schema.CollectionFormatter != nil {
|
||||
apiContext.Schema.CollectionFormatter(apiContext, collection)
|
||||
}
|
||||
|
||||
return collection
|
||||
}
|
||||
|
||||
|
@@ -55,6 +55,8 @@ type Validator func(request *APIContext, schema *Schema, data map[string]interfa
|
||||
|
||||
type Formatter func(request *APIContext, resource *RawResource)
|
||||
|
||||
type CollectionFormatter func(request *APIContext, collection *GenericCollection)
|
||||
|
||||
type ErrorHandler func(request *APIContext, err error)
|
||||
|
||||
type SubContextAttributeProvider interface {
|
||||
|
@@ -112,6 +112,7 @@ type Schema struct {
|
||||
DeleteHandler RequestHandler `json:"-"`
|
||||
UpdateHandler RequestHandler `json:"-"`
|
||||
Formatter Formatter `json:"-"`
|
||||
CollectionFormatter CollectionFormatter `json:"-"`
|
||||
ErrorHandler ErrorHandler `json:"-"`
|
||||
Validator Validator `json:"-"`
|
||||
Store Store `json:"-"`
|
||||
|
Reference in New Issue
Block a user