2024-10-01 17:38:43 +00:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
2024-10-09 00:33:23 +00:00
|
|
|
"somehole.com/service/oauth2/session"
|
|
|
|
"somehole.com/service/router"
|
2024-10-01 17:38:43 +00:00
|
|
|
)
|
|
|
|
|
2024-10-09 00:33:23 +00:00
|
|
|
type CallbackRequestBuilder struct {
|
2024-10-09 04:14:54 +00:00
|
|
|
router.DefaultRequestBuilder
|
2024-10-09 00:33:23 +00:00
|
|
|
values struct {
|
|
|
|
router.Values
|
|
|
|
State session.State `form:"state"`
|
|
|
|
Code session.Code `form:"code"`
|
|
|
|
}
|
2024-10-01 17:38:43 +00:00
|
|
|
}
|
|
|
|
|
2024-10-09 01:27:53 +00:00
|
|
|
func (rb CallbackRequestBuilder) RequestBuilder() router.RequestBuilder {
|
2024-10-09 05:07:57 +00:00
|
|
|
rb.DefaultRequestBuilder = router.NewDefaultRequestBuilder(&rb, CallbackRequestBuilder{}, &ErrorHandler{}, nil, nil, nil, &rb.values.Values, &rb.values, nil, nil)
|
2024-10-09 01:27:53 +00:00
|
|
|
return &rb
|
|
|
|
}
|
|
|
|
|
2024-10-09 00:33:23 +00:00
|
|
|
type CallbackResponse struct {
|
2024-10-09 04:14:54 +00:00
|
|
|
router.DefaultResponse
|
2024-10-09 00:33:23 +00:00
|
|
|
Body struct {
|
2024-10-09 04:14:54 +00:00
|
|
|
router.Body
|
2024-10-09 00:33:23 +00:00
|
|
|
Message string `json:"message"`
|
2024-10-01 17:38:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-09 04:14:54 +00:00
|
|
|
func (r CallbackResponse) Response() router.Response {
|
2024-10-09 05:07:57 +00:00
|
|
|
r.DefaultResponse = router.NewDefaultResponse(&r, CallbackResponse{}, nil, nil, &r.Body.Body, &r.Body)
|
2024-10-09 04:14:54 +00:00
|
|
|
return &r
|
2024-10-01 17:38:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type UnimplementedCallbackServer struct{}
|
|
|
|
|
2024-10-09 00:33:23 +00:00
|
|
|
func (UnimplementedCallbackServer) mustEmbedUnimplementedCallbackServer() {}
|
2024-10-01 17:38:43 +00:00
|
|
|
|
2024-10-09 00:33:23 +00:00
|
|
|
func (UnimplementedCallbackServer) Callback(req *CallbackRequestBuilder) (res *CallbackResponse, errRes router.ErrorResponse) {
|
2024-10-09 05:07:57 +00:00
|
|
|
errRes = &ErrorHandler{router.DefaultErrorNotImplemented}
|
2024-10-01 17:38:43 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
type CallbackServer interface {
|
|
|
|
mustEmbedUnimplementedCallbackServer()
|
2024-10-09 00:50:05 +00:00
|
|
|
Callback(req *CallbackRequestBuilder) (res *CallbackResponse, errRes router.ErrorResponse)
|
2024-10-01 17:38:43 +00:00
|
|
|
}
|