From 16a159acec94fd391e840fab061ed08cf894369f Mon Sep 17 00:00:00 2001 From: Steve Date: Thu, 26 Jan 2017 10:48:40 -0800 Subject: [core] Embedded and implement http.Pusher into http.ResponseWriter+gzip Writer (#47) * added http Pusher interface to gzip response writer * implement Pusher on gzipResponseWriter and pass encoding header to pusher options * providing a generic error view fuction for code that calls a interface method which will have access to the response * fix []byte -> string type for fmt string * adding the res, req pattern for method arguments in interfaces and their method calls * fix for spacing in generic error message * remove default error views displayed in lifecycle hooks - will rely on custom views or redirects inside hook now that user has ResponseWriter. Otherwise, multiple WriteHeader calls would be warned * removing WriteHeader calls before return in external handlers * bump version 0.8.1 --- system/item/item.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'system/item') diff --git a/system/item/item.go b/system/item/item.go index e631b36..e356c7c 100644 --- a/system/item/item.go +++ b/system/item/item.go @@ -42,22 +42,22 @@ 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 { - BeforeSave(req *http.Request) error - AfterSave(req *http.Request) error + BeforeSave(http.ResponseWriter, *http.Request) error + AfterSave(http.ResponseWriter, *http.Request) error - BeforeDelete(req *http.Request) error - AfterDelete(req *http.Request) error + BeforeDelete(http.ResponseWriter, *http.Request) error + AfterDelete(http.ResponseWriter, *http.Request) error - BeforeApprove(req *http.Request) error - AfterApprove(req *http.Request) error + BeforeApprove(http.ResponseWriter, *http.Request) error + AfterApprove(http.ResponseWriter, *http.Request) error - BeforeReject(req *http.Request) error - AfterReject(req *http.Request) error + BeforeReject(http.ResponseWriter, *http.Request) error + AfterReject(http.ResponseWriter, *http.Request) error } // Hideable lets a user keep items hidden type Hideable interface { - Hide(*http.Request) error + Hide(http.ResponseWriter, *http.Request) error } // Pushable lets a user define which values of certain struct fields are @@ -122,42 +122,42 @@ func (i Item) String() string { } // BeforeSave is a no-op to ensure structs which embed Item implement Hookable -func (i Item) BeforeSave(req *http.Request) error { +func (i Item) BeforeSave(res http.ResponseWriter, req *http.Request) error { return nil } // AfterSave is a no-op to ensure structs which embed Item implement Hookable -func (i Item) AfterSave(req *http.Request) error { +func (i Item) AfterSave(res http.ResponseWriter, req *http.Request) error { return nil } // BeforeDelete is a no-op to ensure structs which embed Item implement Hookable -func (i Item) BeforeDelete(req *http.Request) error { +func (i Item) BeforeDelete(res http.ResponseWriter, req *http.Request) error { return nil } // AfterDelete is a no-op to ensure structs which embed Item implement Hookable -func (i Item) AfterDelete(req *http.Request) error { +func (i Item) AfterDelete(res http.ResponseWriter, req *http.Request) error { return nil } // BeforeApprove is a no-op to ensure structs which embed Item implement Hookable -func (i Item) BeforeApprove(req *http.Request) error { +func (i Item) BeforeApprove(res http.ResponseWriter, req *http.Request) error { return nil } // AfterApprove is a no-op to ensure structs which embed Item implement Hookable -func (i Item) AfterApprove(req *http.Request) error { +func (i Item) AfterApprove(res http.ResponseWriter, req *http.Request) error { return nil } // BeforeReject is a no-op to ensure structs which embed Item implement Hookable -func (i Item) BeforeReject(req *http.Request) error { +func (i Item) BeforeReject(res http.ResponseWriter, req *http.Request) error { return nil } // AfterReject is a no-op to ensure structs which embed Item implement Hookable -func (i Item) AfterReject(req *http.Request) error { +func (i Item) AfterReject(res http.ResponseWriter, req *http.Request) error { return nil } -- cgit v1.2.3