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 allowedMethods *[]string
header struct { header struct {
*Header *Header
fields *header fields header
} }
values struct { values struct {
*Values *Values
fields *values fields values
} }
body struct { body struct {
*Body *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{ return DefaultRequestBuilder{
requestBuilder: rb, requestBuilder: rb,
allowedMethods: am, allowedMethods: am,
header: struct { header: struct {
*Header *Header
fields *header fields header
}{ }{
Header: h, Header: h,
fields: hf, fields: hf,
}, },
values: struct { values: struct {
*Values *Values
fields *values fields values
}{ }{
Values: v, Values: v,
fields: vf, fields: vf,
}, },
body: struct { body: struct {
*Body *Body
fields *body fields body
}{ }{
Body: b, Body: b,
fields: bf, fields: bf,
@ -140,13 +162,46 @@ func (rb *DefaultRequestBuilder) Values(values Values) (errRes ErrorResponse) {
} }
type DefaultResponse struct { type DefaultResponse struct {
header struct { response Response
header struct {
*Header *Header
fields *header fields header
} }
body struct { body struct {
*Body *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,
},
} }
} }