diff options
author | Ollie Phillips <oliver@eantics.co.uk> | 2019-03-29 12:05:42 +0000 |
---|---|---|
committer | Ollie Phillips <oliver@eantics.co.uk> | 2019-03-29 12:05:42 +0000 |
commit | 7063494d6c82e784878b6fca79e9442c43578954 (patch) | |
tree | 3e3d9a8b55d08dc548cfb39d8a2f5b7ef1d08c08 /system/item | |
parent | 890c2862327e959411671001c8cc59b319ea57c0 (diff) |
passing data to hooks
Diffstat (limited to 'system/item')
-rw-r--r-- | system/item/item.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/system/item/item.go b/system/item/item.go index 51ac2a9..8be21ae 100644 --- a/system/item/item.go +++ b/system/item/item.go @@ -65,8 +65,8 @@ type Sortable interface { // to the different lifecycles/events a struct may encounter. Item implements // Hookable with no-ops so our user can override only whichever ones necessary. type Hookable interface { - BeforeAPIResponse(http.ResponseWriter, *http.Request) error - AfterAPIResponse(http.ResponseWriter, *http.Request) error + BeforeAPIResponse(http.ResponseWriter, *http.Request, []byte) ([]byte, error) + AfterAPIResponse(http.ResponseWriter, *http.Request, []byte) ([]byte, error) BeforeAPICreate(http.ResponseWriter, *http.Request) error AfterAPICreate(http.ResponseWriter, *http.Request) error @@ -181,13 +181,13 @@ func (i Item) String() string { } // BeforeAPIResponse is a no-op to ensure structs which embed Item implement Hookable -func (i Item) BeforeAPIResponse(res http.ResponseWriter, req *http.Request) error { - return nil +func (i Item) BeforeAPIResponse(res http.ResponseWriter, req *http.Request, data []byte) ([]byte, error) { + return data, nil } // AfterAPIResponse is a no-op to ensure structs which embed Item implement Hookable -func (i Item) AfterAPIResponse(res http.ResponseWriter, req *http.Request) error { - return nil +func (i Item) AfterAPIResponse(res http.ResponseWriter, req *http.Request, data []byte) ([]byte, error) { + return data, nil } // BeforeAPICreate is a no-op to ensure structs which embed Item implement Hookable |