mirror of
https://github.com/rancher/norman.git
synced 2025-09-19 18:16:15 +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)
|
collection.Data = append(collection.Data, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if apiContext.Schema.CollectionFormatter != nil {
|
||||||
|
apiContext.Schema.CollectionFormatter(apiContext, collection)
|
||||||
|
}
|
||||||
|
|
||||||
return 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 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 {
|
||||||
|
@@ -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:"-"`
|
||||||
|
Reference in New Issue
Block a user