oauth2/server/callback.go

48 lines
1.3 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, CallbackRequestBuilder{}, &ErrorHandler{}, 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, CallbackResponse{}, 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 = &ErrorHandler{router.DefaultErrorNotImplemented}
return
}
type CallbackServer interface {
mustEmbedUnimplementedCallbackServer()
Callback(req *CallbackRequestBuilder) (res *CallbackResponse, errRes router.ErrorResponse)
}