component

package
v0.0.0-...-dc9cd6f Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Router

func Router(componentService Service, router *gin.RouterGroup)

Router creates a new Controller and add all available endpoints to a Gin RouterGroup

Types

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller contains all the available handlers

func NewComponentController

func NewComponentController(service Service) *Controller

NewComponentController creates a new Controller

func (*Controller) Create

func (ctrl *Controller) Create(c *gin.Context)

Create it's the handler function for Component creation endpoints

func (*Controller) Delete

func (ctrl *Controller) Delete(c *gin.Context)

Delete it's the handler function for Component deletion endpoints

func (*Controller) Find

func (ctrl *Controller) Find(c *gin.Context)

Find it's the handler function for filtered Component retrieve endpoints

func (*Controller) FindWithLabelFilter

func (ctrl *Controller) FindWithLabelFilter(c *gin.Context)

FindWithLabelFilter it's the handler function for Component retrieve filtered by labels

func (*Controller) List

func (ctrl *Controller) List(c *gin.Context)

List it's the handler function for Component listing endpoints

func (*Controller) ListExistentLabels

func (ctrl *Controller) ListExistentLabels(c *gin.Context)

ListExistentLabels it's the handler function that lists all existent labels

func (*Controller) Update

func (ctrl *Controller) Update(c *gin.Context)

Update it's the handler function for Component update endpoints

type Read

type Read interface {
	Find(queryParam map[string]interface{}) (models.Component, error)
	FindAllWithLabel(label string) ([]models.Component, error)
	List() ([]models.Component, error)
	ListAllLabels() (models.ComponentLabels, error)
}

Read implements the read action methods

type Repository

type Repository interface {
	Read
	Write
}

Repository describes the repository where the data will be written and read from

func NewMongoRepository

func NewMongoRepository(session *mgo.Session) Repository

NewMongoRepository creates a new Repository implementation using the MongoDB as database

type Service

type Service interface {
	ComponentExists(map[string]interface{}) (models.Component, bool)
	CreateComponent(component models.Component) (string, error)
	FindComponent(queryParam map[string]interface{}) (models.Component, error)
	ListComponents(refs []string) ([]models.Component, error)
	RemoveComponent(componentRef string) error
	UpdateComponent(componentRef string, component models.Component) error
	ListAllLabels() (models.ComponentLabels, error)
	ListComponentsWithLabels(labels models.ComponentLabels) ([]models.Component, error)
}

Service describes the use case

func NewService

func NewService(r Repository, l logs.Log) Service

NewService creates implementation of the Service interface

type Write

type Write interface {
	Delete(componentRef string) error
	Insert(component models.Component) (string, error)
	Update(componentRef string, component models.Component) error
}

Write implements the write action methods

Jump to

Keyboard shortcuts

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