Fix Defaults and add constructor for DefaultResponse

This commit is contained in:
some 2024-10-08 22:48:57 -04:00
parent 84a91d56eb
commit 45f1d30f21
Signed by: some
GPG Key ID: 65D0589220B9BFC8

View File

@ -60,39 +60,61 @@ type DefaultRequestBuilder struct {
allowedMethods *[]string
header struct {
*Header
fields *header
fields header
}
values struct {
*Values
fields *values
fields values
}
body struct {
*Body
fields *body
fields body
}
}
func NewDefaultRequestBuilder(rb RequestBuilder, am *[]string, h *Header, hf *header, v *Values, vf *values, b *Body, bf *body) DefaultRequestBuilder {
func NewDefaultRequestBuilder(rb RequestBuilder, am *[]string, h *Header, hf header, v *Values, vf values, b *Body, bf body) DefaultRequestBuilder {
if am == nil {
amd := make([]string, 0)
am = &amd
}
if h == nil || hf == nil {
hd := make(Header)
h = &hd
hfd := struct{ Header }{Header: hd}
hf = &hfd
}
if v == nil || vf == nil {
vd := make(Values)
v = &vd
vfd := struct{ Values }{Values: vd}
vf = &vfd
}
if b == nil || bf == nil {
bd := make(Body, 0)
b = &bd
bfd := struct{ Body }{Body: bd}
bf = &bfd
}
return DefaultRequestBuilder{
requestBuilder: rb,
allowedMethods: am,
header: struct {
*Header
fields *header
fields header
}{
Header: h,
fields: hf,
},
values: struct {
*Values
fields *values
fields values
}{
Values: v,
fields: vf,
},
body: struct {
*Body
fields *body
fields body
}{
Body: b,
fields: bf,
@ -140,13 +162,46 @@ func (rb *DefaultRequestBuilder) Values(values Values) (errRes ErrorResponse) {
}
type DefaultResponse struct {
header struct {
response Response
header struct {
*Header
fields *header
fields header
}
body struct {
*Body
fields *body
fields body
}
}
func NewDefaultResponse(r Response, h *Header, hf header, b *Body, bf body) DefaultResponse {
if h == nil || hf == nil {
hd := make(Header)
h = &hd
hfd := struct{ Header }{Header: hd}
hf = &hfd
}
if b == nil || bf == nil {
bd := make(Body, 0)
b = &bd
bfd := struct{ Body }{Body: bd}
bf = &bfd
}
return DefaultResponse{
response: r,
header: struct {
*Header
fields header
}{
Header: h,
fields: hf,
},
body: struct {
*Body
fields body
}{
Body: b,
fields: bf,
},
}
}