-
Notifications
You must be signed in to change notification settings - Fork 38
/
is_logged_in_user.go
119 lines (94 loc) · 3.19 KB
/
is_logged_in_user.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// Code generated by go-swagger; DO NOT EDIT.
package users
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"context"
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// IsLoggedInUserHandlerFunc turns a function with the right signature into a is logged in user handler
type IsLoggedInUserHandlerFunc func(IsLoggedInUserParams) middleware.Responder
// Handle executing the request and returning a response
func (fn IsLoggedInUserHandlerFunc) Handle(params IsLoggedInUserParams) middleware.Responder {
return fn(params)
}
// IsLoggedInUserHandler interface for that can handle valid is logged in user params
type IsLoggedInUserHandler interface {
Handle(IsLoggedInUserParams) middleware.Responder
}
// NewIsLoggedInUser creates a new http.Handler for the is logged in user operation
func NewIsLoggedInUser(ctx *middleware.Context, handler IsLoggedInUserHandler) *IsLoggedInUser {
return &IsLoggedInUser{Context: ctx, Handler: handler}
}
/*
IsLoggedInUser swagger:route GET /users/is_logged_in users isLoggedInUser
# Returns boolean as to whether the user is logged in
Returns boolean as to whether the user is logged in
*/
type IsLoggedInUser struct {
Context *middleware.Context
Handler IsLoggedInUserHandler
}
func (o *IsLoggedInUser) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewIsLoggedInUserParams()
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params) // actually handle the request
o.Context.Respond(rw, r, route.Produces, route, res)
}
// IsLoggedInUserOKBody is logged in user o k body
//
// swagger:model IsLoggedInUserOKBody
type IsLoggedInUserOKBody struct {
// is logged in
// Required: true
IsLoggedIn *bool `json:"isLoggedIn"`
}
// Validate validates this is logged in user o k body
func (o *IsLoggedInUserOKBody) Validate(formats strfmt.Registry) error {
var res []error
if err := o.validateIsLoggedIn(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (o *IsLoggedInUserOKBody) validateIsLoggedIn(formats strfmt.Registry) error {
if err := validate.Required("isLoggedInUserOK"+"."+"isLoggedIn", "body", o.IsLoggedIn); err != nil {
return err
}
return nil
}
// ContextValidate validates this is logged in user o k body based on context it is used
func (o *IsLoggedInUserOKBody) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (o *IsLoggedInUserOKBody) MarshalBinary() ([]byte, error) {
if o == nil {
return nil, nil
}
return swag.WriteJSON(o)
}
// UnmarshalBinary interface implementation
func (o *IsLoggedInUserOKBody) UnmarshalBinary(b []byte) error {
var res IsLoggedInUserOKBody
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*o = res
return nil
}