Upgrade to use latest router

This commit is contained in:
some 2024-10-09 09:58:26 -04:00
parent 5978bdd406
commit d602e68057
Signed by: some
GPG Key ID: 65D0589220B9BFC8
4 changed files with 40 additions and 10 deletions

2
go.mod
View File

@ -5,7 +5,7 @@ go 1.23.1
require (
somehole.com/common/log v0.1.3
somehole.com/common/security v0.2.1
somehole.com/service/router v0.16.0
somehole.com/service/router v0.17.0
)
require (

4
go.sum
View File

@ -8,5 +8,5 @@ somehole.com/common/log v0.1.3 h1:2PAui0+5EryTAHqVUZQeepLcJTGssHKz2OL+jBknHI0=
somehole.com/common/log v0.1.3/go.mod h1:NS2eHnN120GA6oFbBm3XhB5yHww0eXTbLuMQYZxYNyA=
somehole.com/common/security v0.2.1 h1:H7TpErYKsCOxKYYie75jU7azO5vEgeqrQ9uA+AjXafA=
somehole.com/common/security v0.2.1/go.mod h1:6SMKdIrfxT460XXWafpD6A9yT/ykwipGsGztA5g5vVM=
somehole.com/service/router v0.16.0 h1:h9swbPfyCmXej26nvoXZYIt3RT/sAZPQZnCz1rbLBQk=
somehole.com/service/router v0.16.0/go.mod h1:F+/sNY4/ei7C9QD5+iA+gUHugcOAcrWspHKwX8d8oiM=
somehole.com/service/router v0.17.0 h1:uKod3d3fLxXHK6DVhvA84FGW56XnQpIkkeM5L5Yw2hg=
somehole.com/service/router v0.17.0/go.mod h1:F+/sNY4/ei7C9QD5+iA+gUHugcOAcrWspHKwX8d8oiM=

View File

@ -6,7 +6,7 @@ import (
)
type CallbackRequestBuilder struct {
router.DefaultRequestBuilder
*router.DefaultRequestBuilder
values struct {
router.Values
State session.State `form:"state"`
@ -14,21 +14,36 @@ type CallbackRequestBuilder struct {
}
}
func (*CallbackRequestBuilder) Prototype() router.PrototypeRequestBuilder {
rb := CallbackRequestBuilder{}
rb.DefaultRequestBuilder = router.NewDefaultRequestBuilder().
SetErrorHandler(&ErrorHandler{}).
SetValues(&rb.values.Values, &rb.values).
SetDefaults()
return rb
}
func (rb CallbackRequestBuilder) RequestBuilder() router.RequestBuilder {
rb.DefaultRequestBuilder = router.NewDefaultRequestBuilder(&rb, CallbackRequestBuilder{}, &ErrorHandler{}, nil, nil, nil, &rb.values.Values, &rb.values, nil, nil)
return &rb
}
type CallbackResponse struct {
router.DefaultResponse
*router.DefaultResponse
Body struct {
router.Body
Message string `json:"message"`
}
}
func (*CallbackResponse) Prototype() router.PrototypeResponse {
r := CallbackResponse{}
r.DefaultResponse = router.NewDefaultResponse().
SetBody(&r.Body.Body, &r.Body).
SetDefaults()
return r
}
func (r CallbackResponse) Response() router.Response {
r.DefaultResponse = router.NewDefaultResponse(&r, CallbackResponse{}, nil, nil, &r.Body.Body, &r.Body)
return &r
}

View File

@ -15,13 +15,21 @@ type TokenRequestBuilder struct {
}
}
func (*TokenRequestBuilder) Prototype() router.PrototypeRequestBuilder {
rb := CallbackRequestBuilder{}
rb.DefaultRequestBuilder = router.NewDefaultRequestBuilder().
SetErrorHandler(&ErrorHandler{}).
SetValues(&rb.values.Values, &rb.values).
SetDefaults()
return rb
}
func (rb TokenRequestBuilder) RequestBuilder() router.RequestBuilder {
rb.DefaultRequestBuilder = router.NewDefaultRequestBuilder(&rb, TokenRequestBuilder{}, &ErrorHandler{}, nil, nil, nil, &rb.values.Values, &rb.values, nil, nil)
return &rb
}
type TokenResponse struct {
router.DefaultResponse
*router.DefaultResponse
Body struct {
router.Body
VerificationUri string `json:"verification_uri"`
@ -32,8 +40,15 @@ type TokenResponse struct {
}
}
func (*TokenResponse) Prototype() router.PrototypeResponse {
r := TokenResponse{}
r.DefaultResponse = router.NewDefaultResponse().
SetBody(&r.Body.Body, &r.Body).
SetDefaults()
return r
}
func (r TokenResponse) Response() router.Response {
r.DefaultResponse = router.NewDefaultResponse(&r, TokenResponse{}, nil, nil, &r.Body.Body, &r.Body)
return &r
}