Change unexported request/response to exported
This commit is contained in:
parent
69e5bcefe5
commit
a1c8153d3c
12
default.go
12
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,
|
||||
|
14
server.go
14
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 {
|
||||
|
Loading…
Reference in New Issue
Block a user