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
}
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,

View File

@ -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 {