From a1c8153d3cc083f5c06cef0869b70b37f271370a Mon Sep 17 00:00:00 2001 From: some Date: Thu, 10 Oct 2024 15:12:31 -0400 Subject: [PATCH] Change unexported request/response to exported --- default.go | 12 ++++++------ server.go | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/default.go b/default.go index f821304..995aaec 100644 --- a/default.go +++ b/default.go @@ -43,12 +43,12 @@ func (e DefaultError) String() (out string) { return } -func (e DefaultError) Response() *response { +func (e DefaultError) Response() *GenericResponse { body, err := json.Marshal(struct{ Error string }{Error: e.String()}) if err != nil { panic(err) } - return &response{ + return &GenericResponse{ Status: e.Status(), Header: Header{"Content-Type": []string{"text/javascript", "charset=utf-8"}}, Body: body, @@ -201,8 +201,8 @@ func (rqb *DefaultRequestBuilder) Values(values map[string][]string) (e Error) { return } -func (rqb *DefaultRequestBuilder) Request() (req *request) { - req = &request{ +func (rqb *DefaultRequestBuilder) Request() (req *GenericRequest) { + req = &GenericRequest{ Url: *rqb.url, Header: *rqb.header.Header, Values: *rqb.values.Values, @@ -295,8 +295,8 @@ func (rsb *DefaultResponseBuilder) Write(body []byte) (e Error) { return } -func (rsb *DefaultResponseBuilder) Response() (res *response) { - res = &response{ +func (rsb *DefaultResponseBuilder) Response() (res *GenericResponse) { + res = &GenericResponse{ Status: *rsb.status, Header: *rsb.header.Header, Body: *rsb.body.Body, diff --git a/server.go b/server.go index fcd04c6..a760a17 100644 --- a/server.go +++ b/server.go @@ -8,14 +8,14 @@ import ( "somehole.com/common/log" ) -type response struct { +type GenericResponse struct { Status int Header Header Body Body } type Response[RSB ResponseBuilder] struct { - response + GenericResponse } func NewResponse[RSB ResponseBuilder](rsb RSB) *Response[RSB] { @@ -26,10 +26,10 @@ type Error interface { Error(e Error) (err Error) Status() (code int) String() (out string) - Response() (res *response) + Response() (res *GenericResponse) } -type request struct { +type GenericRequest struct { Url url.URL Header Header Values Values @@ -37,7 +37,7 @@ type request struct { } type Request[RQB RequestBuilder] struct { - request + GenericRequest } func NewRequest[RQB RequestBuilder](rqb RQB) *Request[RQB] { @@ -57,7 +57,7 @@ type RequestBuilder interface { Header(map[string][]string) (err Error) Values(map[string][]string) (err Error) Body(body io.ReadCloser) (err Error) - Request() *request + Request() *GenericRequest } func (*Response[RSB]) ResponseBuilder() ResponseBuilder { @@ -70,7 +70,7 @@ type ResponseBuilder interface { New() (rsb ResponseBuilder) Header(map[string][]string) (err Error) Write(body []byte) (err Error) - Response() *response + Response() *GenericResponse } type writer struct {