Change unexported request/response to exported

This commit is contained in:
some 2024-10-10 15:12:31 -04:00
parent 69e5bcefe5
commit a1c8153d3c
Signed by: some
GPG Key ID: 65D0589220B9BFC8
2 changed files with 13 additions and 13 deletions

View File

@ -43,12 +43,12 @@ func (e DefaultError) String() (out string) {
return return
} }
func (e DefaultError) Response() *response { func (e DefaultError) Response() *GenericResponse {
body, err := json.Marshal(struct{ Error string }{Error: e.String()}) body, err := json.Marshal(struct{ Error string }{Error: e.String()})
if err != nil { if err != nil {
panic(err) panic(err)
} }
return &response{ return &GenericResponse{
Status: e.Status(), Status: e.Status(),
Header: Header{"Content-Type": []string{"text/javascript", "charset=utf-8"}}, Header: Header{"Content-Type": []string{"text/javascript", "charset=utf-8"}},
Body: body, Body: body,
@ -201,8 +201,8 @@ func (rqb *DefaultRequestBuilder) Values(values map[string][]string) (e Error) {
return return
} }
func (rqb *DefaultRequestBuilder) Request() (req *request) { func (rqb *DefaultRequestBuilder) Request() (req *GenericRequest) {
req = &request{ req = &GenericRequest{
Url: *rqb.url, Url: *rqb.url,
Header: *rqb.header.Header, Header: *rqb.header.Header,
Values: *rqb.values.Values, Values: *rqb.values.Values,
@ -295,8 +295,8 @@ func (rsb *DefaultResponseBuilder) Write(body []byte) (e Error) {
return return
} }
func (rsb *DefaultResponseBuilder) Response() (res *response) { func (rsb *DefaultResponseBuilder) Response() (res *GenericResponse) {
res = &response{ res = &GenericResponse{
Status: *rsb.status, Status: *rsb.status,
Header: *rsb.header.Header, Header: *rsb.header.Header,
Body: *rsb.body.Body, Body: *rsb.body.Body,

View File

@ -8,14 +8,14 @@ import (
"somehole.com/common/log" "somehole.com/common/log"
) )
type response struct { type GenericResponse struct {
Status int Status int
Header Header Header Header
Body Body Body Body
} }
type Response[RSB ResponseBuilder] struct { type Response[RSB ResponseBuilder] struct {
response GenericResponse
} }
func NewResponse[RSB ResponseBuilder](rsb RSB) *Response[RSB] { func NewResponse[RSB ResponseBuilder](rsb RSB) *Response[RSB] {
@ -26,10 +26,10 @@ type Error interface {
Error(e Error) (err Error) Error(e Error) (err Error)
Status() (code int) Status() (code int)
String() (out string) String() (out string)
Response() (res *response) Response() (res *GenericResponse)
} }
type request struct { type GenericRequest struct {
Url url.URL Url url.URL
Header Header Header Header
Values Values Values Values
@ -37,7 +37,7 @@ type request struct {
} }
type Request[RQB RequestBuilder] struct { type Request[RQB RequestBuilder] struct {
request GenericRequest
} }
func NewRequest[RQB RequestBuilder](rqb RQB) *Request[RQB] { func NewRequest[RQB RequestBuilder](rqb RQB) *Request[RQB] {
@ -57,7 +57,7 @@ type RequestBuilder interface {
Header(map[string][]string) (err Error) Header(map[string][]string) (err Error)
Values(map[string][]string) (err Error) Values(map[string][]string) (err Error)
Body(body io.ReadCloser) (err Error) Body(body io.ReadCloser) (err Error)
Request() *request Request() *GenericRequest
} }
func (*Response[RSB]) ResponseBuilder() ResponseBuilder { func (*Response[RSB]) ResponseBuilder() ResponseBuilder {
@ -70,7 +70,7 @@ type ResponseBuilder interface {
New() (rsb ResponseBuilder) New() (rsb ResponseBuilder)
Header(map[string][]string) (err Error) Header(map[string][]string) (err Error)
Write(body []byte) (err Error) Write(body []byte) (err Error)
Response() *response Response() *GenericResponse
} }
type writer struct { type writer struct {