From 98f7ce699b559afd74d4e9d607e64b9a8367d762 Mon Sep 17 00:00:00 2001 From: Wolfy-J Date: Sat, 7 Jul 2018 19:23:15 -0700 Subject: attributes support --- service/http/request.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'service/http/request.go') diff --git a/service/http/request.go b/service/http/request.go index 9281a3f5..21566416 100644 --- a/service/http/request.go +++ b/service/http/request.go @@ -44,6 +44,9 @@ type Request struct { // Uploads contains list of uploaded files, their names, sized and associations with temporary files. Uploads *Uploads `json:"uploads"` + // Attributes can be set by chained middleware to safely pass value from Golang to PHP. See: GetAttribute, SetAttribute functions. + Attributes map[string]interface{} `json:"attributes"` + // request body can be parsedData or []byte body interface{} } @@ -51,12 +54,13 @@ type Request struct { // NewRequest creates new PSR7 compatible request using net/http request. func NewRequest(r *http.Request, cfg *UploadsConfig) (req *Request, err error) { req = &Request{ - Protocol: r.Proto, - Method: r.Method, - URI: uri(r), - Headers: r.Header, - Cookies: make(map[string]string), - RawQuery: r.URL.RawQuery, + Protocol: r.Proto, + Method: r.Method, + URI: uri(r), + Headers: r.Header, + Cookies: make(map[string]string), + RawQuery: r.URL.RawQuery, + Attributes: AllAttributes(r), } for _, c := range r.Cookies() { -- cgit v1.2.3