v1

package
v0.0.0-...-0f89c16 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2021 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MONGO_USER_KEY = "MONGO_USERNAME"
	MONGO_PWD_KEY  = "MONGO_PWD"
)

Variables

This section is empty.

Functions

func GetClientConnection

func GetClientConnection() (*mongo.Client, error)

func RunServer

func RunServer(e *echo.Echo, srv Service, addr string) error

Types

type CreateItemRequest

type CreateItemRequest struct {
	Owner    string   `json:"owner,omitempty" bson:"owner,omitempty"`
	Name     string   `json:"name,omitempty" bson:"name,omitempty"`
	Price    float64  `json:"price,omitempty" bson:"price,omitempty"`
	Quantity int      `json:"quantity,omitempty" bson:"quantity,omitempty"`
	Tags     []string `json:"tags,omitempty" bson:"tags,omitempty"`
}

type CreateItemResponse

type CreateItemResponse struct {
	ObjectID primitive.ObjectID `bson:"_id" json:"_id"`
	Owner    string             `json:"owner,omitempty" bson:"owner,omitempty"`
	Name     string             `json:"name,omitempty" bson:"name,omitempty"`
	Price    float64            `json:"price,omitempty" bson:"price,omitempty"`
	Quantity int                `json:"quantity,omitempty" bson:"quantity,omitempty"`
	Tags     []string           `json:"tags,omitempty" bson:"tags,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
}

type Repository

type Repository interface {
	Create(ctx context.Context, in *CreateItemRequest) (*CreateItemResponse, error)
	Retrieve(ctx context.Context, id string) (*RetrieveItemResponse, error)
	Update(ctx context.Context, id string, in *UpdateItemRequest) (*UpdateItemResponse, error)
	Delete(ctx context.Context, id string) error
}

func NewRepoManager

func NewRepoManager(items *mongo.Collection) Repository

type RetrieveItemResponse

type RetrieveItemResponse struct {
	ObjectID primitive.ObjectID `bson:"_id" json:"_id"`
	Owner    string             `json:"owner,omitempty" bson:"owner,omitempty"`
	Name     string             `json:"name,omitempty" bson:"name,omitempty"`
	Price    float64            `json:"price,omitempty" bson:"price,omitempty"`
	Quantity int                `json:"quantity,omitempty" bson:"quantity,omitempty"`
	Tags     []string           `json:"tags,omitempty" bson:"tags,omitempty"`
}

type Service

type Service interface {
	Ping(c echo.Context) error
	Create(c echo.Context) error
	Retrieve(c echo.Context) error
	Update(c echo.Context) error
	Delete(c echo.Context) error
}

func NewService

func NewService(log echo.Logger, repo Repository) Service

type UpdateItemRequest

type UpdateItemRequest struct {
	Owner    string   `json:"owner,omitempty" bson:"owner,omitempty"`
	Name     string   `json:"name,omitempty" bson:"name,omitempty"`
	Price    float64  `json:"price,omitempty" bson:"price,omitempty"`
	Quantity int      `json:"quantity,omitempty" bson:"quantity,omitempty"`
	Tags     []string `json:"tags,omitempty" bson:"tags,omitempty"`
}

type UpdateItemResponse

type UpdateItemResponse struct {
	ObjectID primitive.ObjectID `bson:"_id" json:"_id"`
	Owner    string             `json:"owner,omitempty" bson:"owner,omitempty"`
	Name     string             `json:"name,omitempty" bson:"name,omitempty"`
	Price    float64            `json:"price,omitempty" bson:"price,omitempty"`
	Quantity int                `json:"quantity,omitempty" bson:"quantity,omitempty"`
	Tags     []string           `json:"tags,omitempty" bson:"tags,omitempty"`
}

Jump to

Keyboard shortcuts

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