github.com/dirkm/go-swagger@v0.19.0/examples/oauth2/restapi/operations/get_login.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 "net/http" 10 11 middleware "github.com/go-openapi/runtime/middleware" 12 strfmt "github.com/go-openapi/strfmt" 13 swag "github.com/go-openapi/swag" 14 ) 15 16 // GetLoginHandlerFunc turns a function with the right signature into a get login handler 17 type GetLoginHandlerFunc func(GetLoginParams) middleware.Responder 18 19 // Handle executing the request and returning a response 20 func (fn GetLoginHandlerFunc) Handle(params GetLoginParams) middleware.Responder { 21 return fn(params) 22 } 23 24 // GetLoginHandler interface for that can handle valid get login params 25 type GetLoginHandler interface { 26 Handle(GetLoginParams) middleware.Responder 27 } 28 29 // NewGetLogin creates a new http.Handler for the get login operation 30 func NewGetLogin(ctx *middleware.Context, handler GetLoginHandler) *GetLogin { 31 return &GetLogin{Context: ctx, Handler: handler} 32 } 33 34 /*GetLogin swagger:route GET /login getLogin 35 36 login through oauth2 server 37 38 */ 39 type GetLogin struct { 40 Context *middleware.Context 41 Handler GetLoginHandler 42 } 43 44 func (o *GetLogin) ServeHTTP(rw http.ResponseWriter, r *http.Request) { 45 route, rCtx, _ := o.Context.RouteInfo(r) 46 if rCtx != nil { 47 r = rCtx 48 } 49 var Params = NewGetLoginParams() 50 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 58 o.Context.Respond(rw, r, route.Produces, route, res) 59 60 } 61 62 // GetLoginOKBody get login o k body 63 // swagger:model GetLoginOKBody 64 type GetLoginOKBody struct { 65 66 // access token 67 AccessToken string `json:"access_token,omitempty"` 68 } 69 70 // Validate validates this get login o k body 71 func (o *GetLoginOKBody) Validate(formats strfmt.Registry) error { 72 return nil 73 } 74 75 // MarshalBinary interface implementation 76 func (o *GetLoginOKBody) MarshalBinary() ([]byte, error) { 77 if o == nil { 78 return nil, nil 79 } 80 return swag.WriteJSON(o) 81 } 82 83 // UnmarshalBinary interface implementation 84 func (o *GetLoginOKBody) UnmarshalBinary(b []byte) error { 85 var res GetLoginOKBody 86 if err := swag.ReadJSON(b, &res); err != nil { 87 return err 88 } 89 *o = res 90 return nil 91 }