1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-19 01:17:04 +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)
}
}
if apiContext.Schema.CollectionFormatter != nil {
apiContext.Schema.CollectionFormatter(apiContext, 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 CollectionFormatter func(request *APIContext, collection *GenericCollection)
type ErrorHandler func(request *APIContext, err error)
type SubContextAttributeProvider interface {

View File

@@ -103,18 +103,19 @@ type Schema struct {
CollectionFilters map[string]Filter `json:"collectionFilters,omitempty"`
Scope TypeScope `json:"-"`
InternalSchema *Schema `json:"-"`
Mapper Mapper `json:"-"`
ActionHandler ActionHandler `json:"-"`
LinkHandler RequestHandler `json:"-"`
ListHandler RequestHandler `json:"-"`
CreateHandler RequestHandler `json:"-"`
DeleteHandler RequestHandler `json:"-"`
UpdateHandler RequestHandler `json:"-"`
Formatter Formatter `json:"-"`
ErrorHandler ErrorHandler `json:"-"`
Validator Validator `json:"-"`
Store Store `json:"-"`
InternalSchema *Schema `json:"-"`
Mapper Mapper `json:"-"`
ActionHandler ActionHandler `json:"-"`
LinkHandler RequestHandler `json:"-"`
ListHandler RequestHandler `json:"-"`
CreateHandler RequestHandler `json:"-"`
DeleteHandler RequestHandler `json:"-"`
UpdateHandler RequestHandler `json:"-"`
Formatter Formatter `json:"-"`
CollectionFormatter CollectionFormatter `json:"-"`
ErrorHandler ErrorHandler `json:"-"`
Validator Validator `json:"-"`
Store Store `json:"-"`
}
type Field struct {