github.com/circl-dev/go-swagger@v0.31.0/examples/oauth2/restapi/operations/get_auth_callback.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package operations 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the generate command 7 8 import ( 9 "context" 10 "net/http" 11 12 "github.com/go-openapi/strfmt" 13 "github.com/go-openapi/swag" 14 "github.com/circl-dev/runtime/middleware" 15 ) 16 17 // GetAuthCallbackHandlerFunc turns a function with the right signature into a get auth callback handler 18 type GetAuthCallbackHandlerFunc func(GetAuthCallbackParams) middleware.Responder 19 20 // Handle executing the request and returning a response 21 func (fn GetAuthCallbackHandlerFunc) Handle(params GetAuthCallbackParams) middleware.Responder { 22 return fn(params) 23 } 24 25 // GetAuthCallbackHandler interface for that can handle valid get auth callback params 26 type GetAuthCallbackHandler interface { 27 Handle(GetAuthCallbackParams) middleware.Responder 28 } 29 30 // NewGetAuthCallback creates a new http.Handler for the get auth callback operation 31 func NewGetAuthCallback(ctx *middleware.Context, handler GetAuthCallbackHandler) *GetAuthCallback { 32 return &GetAuthCallback{Context: ctx, Handler: handler} 33 } 34 35 /* GetAuthCallback swagger:route GET /auth/callback getAuthCallback 36 37 return access_token 38 39 */ 40 type GetAuthCallback struct { 41 Context *middleware.Context 42 Handler GetAuthCallbackHandler 43 } 44 45 func (o *GetAuthCallback) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 46 route, rCtx, _ := o.Context.RouteInfo(r) 47 if rCtx != nil { 48 *r = *rCtx 49 } 50 var Params = NewGetAuthCallbackParams() 51 if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params 52 o.Context.Respond(rw, r, route.Produces, route, err) 53 return 54 } 55 56 res := o.Handler.Handle(Params) // actually handle the request 57 o.Context.Respond(rw, r, route.Produces, route, res) 58 59 } 60 61 // GetAuthCallbackOKBody get auth callback o k body 62 // 63 // swagger:model GetAuthCallbackOKBody 64 type GetAuthCallbackOKBody struct { 65 66 // access token 67 AccessToken string `json:"access_token,omitempty"` 68 } 69 70 // Validate validates this get auth callback o k body 71 func (o *GetAuthCallbackOKBody) Validate(formats strfmt.Registry) error { 72 return nil 73 } 74 75 // ContextValidate validates this get auth callback o k body based on context it is used 76 func (o *GetAuthCallbackOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 77 return nil 78 } 79 80 // MarshalBinary interface implementation 81 func (o *GetAuthCallbackOKBody) MarshalBinary() ([]byte, error) { 82 if o == nil { 83 return nil, nil 84 } 85 return swag.WriteJSON(o) 86 } 87 88 // UnmarshalBinary interface implementation 89 func (o *GetAuthCallbackOKBody) UnmarshalBinary(b []byte) error { 90 var res GetAuthCallbackOKBody 91 if err := swag.ReadJSON(b, &res); err != nil { 92 return err 93 } 94 *o = res 95 return nil 96 }