Documentation ¶
Overview ¶
Package internal provides primitives to interact with the openapi HTTP API.
Code generated by github.com/deepmap/oapi-codegen version v1.8.2 DO NOT EDIT.
Package internal provides primitives to interact with the openapi HTTP API.
Code generated by github.com/deepmap/oapi-codegen version v1.8.2 DO NOT EDIT.
Index ¶
- Variables
- func Handler(si ServerInterface) http.Handler
- func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler
- func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler
- func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler
- type ChiServerOptions
- type Email
- type EmailResponse
- type MiddlewareFunc
- type PatchUserJSONBody
- type PatchUserJSONRequestBody
- type PatchUserRequest
- type PostUserJSONBody
- type PostUserJSONRequestBody
- type PostUserRequest
- type ServerInterface
- type ServerInterfaceWrapper
- func (siw *ServerInterfaceWrapper) DeleteUser(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetUser(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) GetUsers(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PatchUser(w http.ResponseWriter, r *http.Request)
- func (siw *ServerInterfaceWrapper) PostUser(w http.ResponseWriter, r *http.Request)
- type User
- type UserHandler
- func (h UserHandler) DeleteUser(w http.ResponseWriter, r *http.Request, rawUserID UserID)
- func (h UserHandler) GetUser(w http.ResponseWriter, r *http.Request, rawUserID UserID)
- func (h UserHandler) GetUsers(w http.ResponseWriter, r *http.Request)
- func (h UserHandler) PatchUser(w http.ResponseWriter, r *http.Request, rawUserID UserID)
- func (h UserHandler) PostUser(w http.ResponseWriter, r *http.Request)
- type UserID
- type UserResponse
- type UserStorage
- func (s UserStorage) Add(ctx context.Context, user User) (err error)
- func (s UserStorage) All(ctx context.Context) ([]User, error)
- func (s UserStorage) ByID(ctx context.Context, id int) (User, error)
- func (s UserStorage) Delete(ctx context.Context, id int) error
- func (s UserStorage) Update(ctx context.Context, user User) error
- type UsersResponse
Constants ¶
This section is empty.
Variables ¶
var ( ErrUserNotFound = errors.New("user not found") ErrEmailAlreadyExists = errors.New("email already exists") )
Functions ¶
func Handler ¶
func Handler(si ServerInterface) http.Handler
Handler creates http.Handler with routing matching OpenAPI spec.
func HandlerFromMux ¶
func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler
HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.
func HandlerFromMuxWithBaseURL ¶
func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler
func HandlerWithOptions ¶
func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler
HandlerWithOptions creates http.Handler with additional options
Types ¶
type ChiServerOptions ¶
type ChiServerOptions struct { BaseURL string BaseRouter chi.Router Middlewares []MiddlewareFunc }
type Email ¶
type Email struct {
// contains filtered or unexported fields
}
func UnmarshalEmail ¶
UnmarshalEmail loads the e-mail from database data. It shouldn't be used for anything else.
type EmailResponse ¶
EmailResponse defines model for EmailResponse.
type MiddlewareFunc ¶
type MiddlewareFunc func(http.HandlerFunc) http.HandlerFunc
type PatchUserJSONBody ¶
type PatchUserJSONBody PatchUserRequest
PatchUserJSONBody defines parameters for PatchUser.
type PatchUserJSONRequestBody ¶
type PatchUserJSONRequestBody PatchUserJSONBody
PatchUserJSONRequestBody defines body for PatchUser for application/json ContentType.
type PatchUserRequest ¶
type PatchUserRequest struct { // First name FirstName *string `json:"first_name,omitempty"` // Last name LastName *string `json:"last_name,omitempty"` }
PatchUserRequest defines model for PatchUserRequest.
type PostUserJSONBody ¶
type PostUserJSONBody PostUserRequest
PostUserJSONBody defines parameters for PostUser.
type PostUserJSONRequestBody ¶
type PostUserJSONRequestBody PostUserJSONBody
PostUserJSONRequestBody defines body for PostUser for application/json ContentType.
type PostUserRequest ¶
type PostUserRequest struct { // E-mail Email string `json:"email"` // First name FirstName string `json:"first_name"` // Last name LastName string `json:"last_name"` }
PostUserRequest defines model for PostUserRequest.
type ServerInterface ¶
type ServerInterface interface { // Get all users // (GET /users) GetUsers(w http.ResponseWriter, r *http.Request) // Add a new user // (POST /users) PostUser(w http.ResponseWriter, r *http.Request) // Delete user // (DELETE /users/{userID}) DeleteUser(w http.ResponseWriter, r *http.Request, userID UserID) // Get a single user // (GET /users/{userID}) GetUser(w http.ResponseWriter, r *http.Request, userID UserID) // Update user // (PATCH /users/{userID}) PatchUser(w http.ResponseWriter, r *http.Request, userID UserID) }
ServerInterface represents all server handlers.
type ServerInterfaceWrapper ¶
type ServerInterfaceWrapper struct { Handler ServerInterface HandlerMiddlewares []MiddlewareFunc }
ServerInterfaceWrapper converts contexts to parameters.
func (*ServerInterfaceWrapper) DeleteUser ¶
func (siw *ServerInterfaceWrapper) DeleteUser(w http.ResponseWriter, r *http.Request)
DeleteUser operation middleware
func (*ServerInterfaceWrapper) GetUser ¶
func (siw *ServerInterfaceWrapper) GetUser(w http.ResponseWriter, r *http.Request)
GetUser operation middleware
func (*ServerInterfaceWrapper) GetUsers ¶
func (siw *ServerInterfaceWrapper) GetUsers(w http.ResponseWriter, r *http.Request)
GetUsers operation middleware
func (*ServerInterfaceWrapper) PatchUser ¶
func (siw *ServerInterfaceWrapper) PatchUser(w http.ResponseWriter, r *http.Request)
PatchUser operation middleware
func (*ServerInterfaceWrapper) PostUser ¶
func (siw *ServerInterfaceWrapper) PostUser(w http.ResponseWriter, r *http.Request)
PostUser operation middleware
type User ¶
type User struct {
// contains filtered or unexported fields
}
func UnmarshalUser ¶
UnmarshalUser loads the user from database data. It shouldn't be used for anything else.
func (*User) ChangeName ¶
func (User) DisplayName ¶
func (User) PrimaryEmail ¶
type UserHandler ¶
type UserHandler struct {
// contains filtered or unexported fields
}
func NewUserHandler ¶
func NewUserHandler(storage UserStorage) UserHandler
func (UserHandler) DeleteUser ¶
func (h UserHandler) DeleteUser(w http.ResponseWriter, r *http.Request, rawUserID UserID)
func (UserHandler) GetUser ¶
func (h UserHandler) GetUser(w http.ResponseWriter, r *http.Request, rawUserID UserID)
func (UserHandler) GetUsers ¶
func (h UserHandler) GetUsers(w http.ResponseWriter, r *http.Request)
func (UserHandler) PatchUser ¶
func (h UserHandler) PatchUser(w http.ResponseWriter, r *http.Request, rawUserID UserID)
func (UserHandler) PostUser ¶
func (h UserHandler) PostUser(w http.ResponseWriter, r *http.Request)
type UserResponse ¶
type UserResponse struct { DisplayName string `json:"display_name"` Emails []EmailResponse `json:"emails"` FirstName string `json:"first_name"` Id int `json:"id"` LastName string `json:"last_name"` }
UserResponse defines model for UserResponse.
type UserStorage ¶
type UserStorage struct {
// contains filtered or unexported fields
}
func NewUserStorage ¶
func NewUserStorage(db *sql.DB) UserStorage
type UsersResponse ¶
type UsersResponse []UserResponse
UsersResponse defines model for UsersResponse.