github.com/kaisawind/go-swagger@v0.19.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  	"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  // GetAuthCallbackHandlerFunc turns a function with the right signature into a get auth callback handler
    17  type GetAuthCallbackHandlerFunc func(GetAuthCallbackParams) middleware.Responder
    18  
    19  // Handle executing the request and returning a response
    20  func (fn GetAuthCallbackHandlerFunc) Handle(params GetAuthCallbackParams) middleware.Responder {
    21  	return fn(params)
    22  }
    23  
    24  // GetAuthCallbackHandler interface for that can handle valid get auth callback params
    25  type GetAuthCallbackHandler interface {
    26  	Handle(GetAuthCallbackParams) middleware.Responder
    27  }
    28  
    29  // NewGetAuthCallback creates a new http.Handler for the get auth callback operation
    30  func NewGetAuthCallback(ctx *middleware.Context, handler GetAuthCallbackHandler) *GetAuthCallback {
    31  	return &GetAuthCallback{Context: ctx, Handler: handler}
    32  }
    33  
    34  /*GetAuthCallback swagger:route GET /auth/callback getAuthCallback
    35  
    36  return access_token
    37  
    38  */
    39  type GetAuthCallback struct {
    40  	Context *middleware.Context
    41  	Handler GetAuthCallbackHandler
    42  }
    43  
    44  func (o *GetAuthCallback) 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 = NewGetAuthCallbackParams()
    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  // GetAuthCallbackOKBody get auth callback o k body
    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  // MarshalBinary interface implementation
    76  func (o *GetAuthCallbackOKBody) 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 *GetAuthCallbackOKBody) UnmarshalBinary(b []byte) error {
    85  	var res GetAuthCallbackOKBody
    86  	if err := swag.ReadJSON(b, &res); err != nil {
    87  		return err
    88  	}
    89  	*o = res
    90  	return nil
    91  }