oauth2/server/callback.go
2024-10-09 00:14:54 -04:00

48 lines
1.2 KiB
Go

package server
import (
"somehole.com/service/oauth2/session"
"somehole.com/service/router"
)
type CallbackRequestBuilder struct {
router.DefaultRequestBuilder
values struct {
router.Values
State session.State `form:"state"`
Code session.Code `form:"code"`
}
}
func (rb CallbackRequestBuilder) RequestBuilder() router.RequestBuilder {
rb.DefaultRequestBuilder = router.NewDefaultRequestBuilder(&rb, nil, nil, nil, &rb.values.Values, &rb.values, nil, nil)
return &rb
}
type CallbackResponse struct {
router.DefaultResponse
Body struct {
router.Body
Message string `json:"message"`
}
}
func (r CallbackResponse) Response() router.Response {
r.DefaultResponse = router.NewDefaultResponse(&r, nil, nil, &r.Body.Body, &r.Body)
return &r
}
type UnimplementedCallbackServer struct{}
func (UnimplementedCallbackServer) mustEmbedUnimplementedCallbackServer() {}
func (UnimplementedCallbackServer) Callback(req *CallbackRequestBuilder) (res *CallbackResponse, errRes router.ErrorResponse) {
errRes = ErrorNotImplemented
return
}
type CallbackServer interface {
mustEmbedUnimplementedCallbackServer()
Callback(req *CallbackRequestBuilder) (res *CallbackResponse, errRes router.ErrorResponse)
}