internal

package
v0.0.0-...-9060cdc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2022 License: MIT Imports: 16 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var (
	ErrUserNotFound       = errors.New("user not found")
	ErrEmailAlreadyExists = errors.New("email already exists")
)
View Source
var (
	ErrNameRequired  = errors.New("either first name or last name is required")
	ErrEmailRequired = errors.New("email address is required")
	ErrInvalidEmail  = errors.New("invalid email address")
)

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 NewEmail

func NewEmail(address string, primary bool) (Email, error)

func UnmarshalEmail

func UnmarshalEmail(address string, primary bool) Email

UnmarshalEmail loads the e-mail from database data. It shouldn't be used for anything else.

func (Email) Address

func (e Email) Address() string

func (Email) Primary

func (e Email) Primary() bool

type EmailResponse

type EmailResponse struct {
	Address string `json:"address"`
	Primary bool   `json:"primary"`
}

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

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 NewUser

func NewUser(firstName string, lastName string, emailAddress string) (User, error)

func UnmarshalUser

func UnmarshalUser(id int, firstName string, lastName string, emails []Email) User

UnmarshalUser loads the user from database data. It shouldn't be used for anything else.

func (*User) ChangeName

func (u *User) ChangeName(newFirstName *string, newLastName *string) error

func (User) DisplayName

func (u User) DisplayName() string

func (User) Emails

func (u User) Emails() []Email

func (User) FirstName

func (u User) FirstName() string

func (User) ID

func (u User) ID() int

func (User) LastName

func (u User) LastName() string

func (User) PrimaryEmail

func (u User) PrimaryEmail() Email

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 UserID

type UserID string

UserID defines model for userID.

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

func (UserStorage) Add

func (s UserStorage) Add(ctx context.Context, user User) (err error)

func (UserStorage) All

func (s UserStorage) All(ctx context.Context) ([]User, error)

func (UserStorage) ByID

func (s UserStorage) ByID(ctx context.Context, id int) (User, error)

func (UserStorage) Delete

func (s UserStorage) Delete(ctx context.Context, id int) error

func (UserStorage) Update

func (s UserStorage) Update(ctx context.Context, user User) error

type UsersResponse

type UsersResponse []UserResponse

UsersResponse defines model for UsersResponse.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL