controllers

package
v0.0.0-...-686e1fb Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContentTypeApplicationJSON represent the applcation/json Content-Type value
	ContentTypeApplicationJSON = "application/json"
)

Variables

View Source
var (
	ErrIDNotFound   = NewErrorResponse(http.StatusBadRequest, "id cannot be empty")
	ErrIDNotInteger = NewErrorResponse(http.StatusBadRequest, "id must be an integer")
)

Functions

This section is empty.

Types

type BeansResponse

type BeansResponse struct {
	// swagger:allOf
	bean.Bean
}

BeansResponse represents coffee beans for this application

Beans have a name, a roaster, a roast date and a roast level.

swagger:response BeansResponse

type CreateBeansParams

type CreateBeansParams struct {
	// The request body for creating beans
	// in: body
	// required: true
	Body CreateBeansRequest
}

swagger:parameters createBeans

type CreateBeansRequest

type CreateBeansRequest struct {
	Name       string         `json:"name"`
	RoasterId  int            `json:"roaster_id"`
	RoastDate  RoastDate      `json:"roast_date"`
	RoastLevel sql.RoastLevel `json:"roast_level"`
}

CreateBeansRequest represents the request body for creating beans swagger:model

type CreateRoasterParams

type CreateRoasterParams struct {
	// The request body for creating a roaster
	// in: body
	// required: true
	Body CreateRoasterRequest
}

swagger:parameters createRoaster

type CreateRoasterRequest

type CreateRoasterRequest struct {
	Name string `json:"name"`
}

CreateRoasterRequest represents the request body for creating a roaster swagger:model

type CreateSheetParams

type CreateSheetParams struct {
	// The request body for creating a sheet
	// in: body
	// required: true
	Body CreateSheetRequest
}

swagger:parameters createSheet

type CreateSheetRequest

type CreateSheetRequest struct {
	Name string `json:"name"`
}

CreateSheetRequest represents the request body for creating a sheet swagger:model

type CreateShotParams

type CreateShotParams struct {
	// The request body for creating a shot
	// in: body
	// required: true
	Body CreateShotRequest
}

swagger:parameters createShot

type CreateShotRequest

type CreateShotRequest struct {
	SheetId                       int                               `json:"sheet_id"`
	BeansId                       int                               `json:"beans_id"`
	GrindSetting                  int                               `json:"grind_setting"`
	QuantityIn                    float64                           `json:"quantity_in"`
	QuantityOut                   float64                           `json:"quantity_out"`
	ShotTime                      time.Duration                     `json:"shot_time"`
	WaterTemperature              float64                           `json:"water_temperature"`
	Rating                        float64                           `json:"rating"`
	IsTooBitter                   bool                              `json:"is_too_bitter"`
	IsTooSour                     bool                              `json:"is_too_sour"`
	ComparaisonWithPreviousResult sql.ComparaisonWithPreviousResult `json:"comparaison_with_previous_result"`
	AdditionalNotes               string                            `json:"additional_notes"`
}

CreateShotRequest represents the request body for creating a shot swagger:model

type ErrorResponse

type ErrorResponse struct {
	Msg string `json:"msg"`
	// contains filtered or unexported fields
}

ErrorResponse represents the json response for http errors. It contains a message describing the error

swagger:response ErrorResponse

func NewErrorResponse

func NewErrorResponse(status int, msg string) *ErrorResponse

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

Error method for ErrorResponse

func (*ErrorResponse) StatusCode

func (e *ErrorResponse) StatusCode() int

StatusCode method for ErrorResponse

type Handler

type Handler struct {
	SheetService   sheet.Service
	RoasterService roaster.Service
	BeanService    bean.Service
	ShotService    shot.Service
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(
	sheetService sheet.Service,
	roasterService roaster.Service,
	beanService bean.Service,
	ShotService shot.Service,
	serverMaxRequestSize int64) *Handler

func (*Handler) CreateBeans deprecated

func (h *Handler) CreateBeans(w http.ResponseWriter, r *http.Request)

swagger:route POST /rest/v1/beans beans createBeans

Create beans

This will create new beans.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Deprecated: false

Security:
  api_key:
  oauth:

Responses:
  201: BeansResponse
  400: ErrorResponse
  409: ErrorResponse
  413: ErrorResponse

func (*Handler) CreateRoaster deprecated

func (h *Handler) CreateRoaster(w http.ResponseWriter, r *http.Request)

swagger:route POST /rest/v1/roasters roasters createRoaster

Create roasters

This will create a new roaster.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Deprecated: false

Security:
  api_key:
  oauth:

Responses:
  201: RoasterResponse
  400: ErrorResponse
  409: ErrorResponse
  413: ErrorResponse

func (*Handler) CreateSheet deprecated

func (h *Handler) CreateSheet(w http.ResponseWriter, r *http.Request)

swagger:route POST /rest/v1/sheets sheets createSheet

Create sheets

This will create a new sheet.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Deprecated: false

Security:
  api_key:
  oauth:

Responses:
  201: SheetResponse
  400: ErrorResponse
  409: ErrorResponse
  413: ErrorResponse

func (*Handler) CreateShot deprecated

func (h *Handler) CreateShot(w http.ResponseWriter, r *http.Request)

swagger:route POST /rest/v1/shots shots createShot

Create shots

This will create a new shot.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Deprecated: false

Security:
  api_key:
  oauth:

Responses:
  201: ShotResponse
  400: ErrorResponse
  409: ErrorResponse
  413: ErrorResponse

func (*Handler) DeleteBeansById deprecated

func (h *Handler) DeleteBeansById(w http.ResponseWriter, r *http.Request)

swagger:route DELETE /rest/v1/beans/{id} beans deleteBeans

Delete beans

This will delete beans by its given id.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Deprecated: false

Security:
  api_key:
  oauth:

Parameters:
  + name: id
    in: path
    description: id of the beans to delete
    required: true
    type: integer
    format: int32

Responses:
  200: ItemDeletedResponse
  400: ErrorResponse
  404: ErrorResponse

func (*Handler) DeleteRoasterById deprecated

func (h *Handler) DeleteRoasterById(w http.ResponseWriter, r *http.Request)

swagger:route DELETE /rest/v1/roasters/{id} roasters deleteRoaster

Delete roasters

This will delete a roaster by its given id.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Deprecated: false

Security:
  api_key:
  oauth:

Parameters:
  + name: id
    in: path
    description: id of the roaster to delete
    required: true
    type: integer
    format: int32

Responses:
  200: ItemDeletedResponse
  400: ErrorResponse
  404: ErrorResponse

func (*Handler) DeleteSheetById deprecated

func (h *Handler) DeleteSheetById(w http.ResponseWriter, r *http.Request)

swagger:route DELETE /rest/v1/sheets/{id} sheets deleteSheet

Delete sheets

This will delete a sheet by its given id.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Deprecated: false

Security:
  api_key:
  oauth:

Parameters:
  + name: id
    in: path
    description: id of the sheet to delete
    required: true
    type: integer
    format: int32

Responses:
  200: ItemDeletedResponse
  400: ErrorResponse
  404: ErrorResponse

func (*Handler) DeleteShotById deprecated

func (h *Handler) DeleteShotById(w http.ResponseWriter, r *http.Request)

swagger:route DELETE /rest/v1/shots/{id} shots deleteShot

Delete shots

This will delete a shot by its given id.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Deprecated: false

Security:
  api_key:
  oauth:

Parameters:
  + name: id
    in: path
    description: id of the shot to delete
    required: true
    type: integer
    format: int32

Responses:
  200: ItemDeletedResponse
  400: ErrorResponse
  404: ErrorResponse

func (*Handler) GetAllBeans deprecated

func (h *Handler) GetAllBeans(w http.ResponseWriter, r *http.Request)

swagger:route GET /rest/v1/beans beans getAllBeans

Get all beans

This will show all beans by default.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Deprecated: false

Security:
  api_key:
  oauth:

Responses:
  200: BeansResponse
  400: ErrorResponse
  404: ErrorResponse

func (*Handler) GetAllRoasters deprecated

func (h *Handler) GetAllRoasters(w http.ResponseWriter, r *http.Request)

swagger:route GET /rest/v1/roasters roasters getAllRoasters

Get all roasters

This will show all roasters by default.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Deprecated: false

Security:
  api_key:
  oauth:

Responses:
  200: RoasterResponse
  400: ErrorResponse
  404: ErrorResponse

func (*Handler) GetAllSheets deprecated

func (h *Handler) GetAllSheets(w http.ResponseWriter, r *http.Request)

swagger:route GET /rest/v1/sheets sheets getAllSheets

Get all sheets

This will show all sheets by default.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Deprecated: false

Security:
  api_key:
  oauth:

Responses:
  200: SheetResponse
  400: ErrorResponse
  404: ErrorResponse

func (*Handler) GetAllShots deprecated

func (h *Handler) GetAllShots(w http.ResponseWriter, r *http.Request)

swagger:route GET /rest/v1/shots shots getAllShots

Get all shots

This will show all shots by default.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Deprecated: false

Security:
  api_key:
  oauth:

Responses:
  200: ShotResponse
  400: ErrorResponse
  404: ErrorResponse

func (*Handler) GetBeansById deprecated

func (h *Handler) GetBeansById(w http.ResponseWriter, r *http.Request)

swagger:route GET /rest/v1/beans/{id} beans getBeans

Get beans

This will get the beans with the given id.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Deprecated: false

Security:
  api_key:
  oauth:

Parameters:
  + name: id
    in: path
    description: id of the beans to get
    required: true
    type: integer
    format: int32

Responses:
  200: BeansResponse
  400: ErrorResponse
  404: ErrorResponse

func (*Handler) GetRoasterById deprecated

func (h *Handler) GetRoasterById(w http.ResponseWriter, r *http.Request)

swagger:route GET /rest/v1/roasters/{id} roasters getRoaster

Get roasters

This will get the roaster with the given id.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Deprecated: false

Security:
  api_key:
  oauth:

Parameters:
  + name: id
    in: path
    description: id of the roaster to get
    required: true
    type: integer
    format: int32

Responses:
  200: RoasterResponse
  400: ErrorResponse
  404: ErrorResponse

func (*Handler) GetSheetById deprecated

func (h *Handler) GetSheetById(w http.ResponseWriter, r *http.Request)

swagger:route GET /rest/v1/sheets/{id} sheets getSheet

Get sheets

This will get the sheet with the given id.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Deprecated: false

Security:
  api_key:
  oauth:

Parameters:
  + name: id
    in: path
    description: id of the sheet to get
    required: true
    type: integer
    format: int32

Responses:
  200: SheetResponse
  400: ErrorResponse
  404: ErrorResponse

func (*Handler) GetShotById deprecated

func (h *Handler) GetShotById(w http.ResponseWriter, r *http.Request)

swagger:route GET /rest/v1/shots/{id} shots getShot

Get shots

This will get the shot with the given id.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Deprecated: false

Security:
  api_key:
  oauth:

Parameters:
  + name: id
    in: path
    description: id of the shot to get
    required: true
    type: integer
    format: int32

Responses:
  200: ShotResponse
  400: ErrorResponse
  404: ErrorResponse

func (*Handler) IdParameterLoggerHandler

func (h *Handler) IdParameterLoggerHandler(fieldKey string) func(next http.Handler) http.Handler

IdParameterLoggerHandler returns a middleware function that logs the value of the specified field key from the request URL parameters.

func (*Handler) MaxReqSize

func (h *Handler) MaxReqSize() func(next http.Handler) http.Handler

MaxReqSize is a HTTP middleware limiting the size of the request by using http.MaxBytesReader() on the request body.

func (*Handler) Ping

func (h *Handler) Ping(w http.ResponseWriter, r *http.Request)

func (*Handler) SetErrorResponse

func (h *Handler) SetErrorResponse(w http.ResponseWriter, err error)

SetErrorResponse will attempt to parse the given error and set the response status code and using the ResponseWriter according to the type of the error.

func (*Handler) Swagger

func (h *Handler) Swagger(w http.ResponseWriter, r *http.Request)

func (*Handler) UpdateBeanById deprecated

func (h *Handler) UpdateBeanById(w http.ResponseWriter, r *http.Request)

swagger:route PUT /rest/v1/beans/{id} beans updateBeansById

Update beans

This will update beans by its given id.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Deprecated: false

Security:
  api_key:
  oauth:

Parameters:
  + name: id
    in: path
    description: id of the beans to update
    required: true
    type: integer
    format: int32

Responses:
  200: BeansResponse
  400: ErrorResponse
  404: ErrorResponse
  413: ErrorResponse

func (*Handler) UpdateRoasterById deprecated

func (h *Handler) UpdateRoasterById(w http.ResponseWriter, r *http.Request)

swagger:route PUT /rest/v1/roasters/{id} roasters updateRoasterById

Update roasters

This will update a roaster by its given id.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Deprecated: false

Security:
  api_key:
  oauth:

Parameters:
  + name: id
    in: path
    description: id of the roaster to update
    required: true
    type: integer
    format: int32

Responses:
  200: RoasterResponse
  400: ErrorResponse
  404: ErrorResponse
  413: ErrorResponse

func (*Handler) UpdateSheetById deprecated

func (h *Handler) UpdateSheetById(w http.ResponseWriter, r *http.Request)

swagger:route PUT /rest/v1/sheets/{id} sheets updateSheetById

Update sheets

This will update a sheet by its given id.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Deprecated: false

Security:
  api_key:
  oauth:

Parameters:
  + name: id
    in: path
    description: id of the sheet to update
    required: true
    type: integer
    format: int32

Responses:
  200: SheetResponse
  400: ErrorResponse
  404: ErrorResponse
  413: ErrorResponse

func (*Handler) UpdateShotById deprecated

func (h *Handler) UpdateShotById(w http.ResponseWriter, r *http.Request)

swagger:route PUT /rest/v1/shots/{id} shots updateShotById

Update shots

This will update a shot by its given id.

Consumes:
- application/json

Produces:
- application/json

Schemes: http, https

Deprecated: false

Security:
  api_key:
  oauth:

Parameters:
  + name: id
    in: path
    description: id of the shot to update
    required: true
    type: integer
    format: int32

Responses:
  200: ShotResponse
  400: ErrorResponse
  404: ErrorResponse
  413: ErrorResponse

type ItemDeletedResponse

type ItemDeletedResponse struct {
	Id  int    `json:"id"`
	Msg string `json:"msg"`
}

ItemDeletedResponse represents the response when an item is deleted swagger:model

type PingResponse

type PingResponse struct {
	Ping string `json:"ping"`
}

PingResponse represents the json response of a /ping endpoint

type RoastDate

type RoastDate time.Time

func (RoastDate) MarshalJSON

func (r RoastDate) MarshalJSON() ([]byte, error)

func (*RoastDate) UnmarshalJSON

func (r *RoastDate) UnmarshalJSON(b []byte) error

Implement Marshaler and Unmarshaler interface

type RoasterResponse

type RoasterResponse struct {
	// swagger:allOf
	roaster.Roaster
}

RoasterResponse represents a roaster for this application

A roaster is the professional who roasts coffee beans.

swagger:response RoasterResponse

type SheetResponse

type SheetResponse struct {
	// swagger:allOf
	sheet.Sheet
}

SheetResponse represents a sheet for this application

A sheet is a collection of shots. It's used to group shots together in a logical way.

swagger:response SheetResponse

type ShotResponse

type ShotResponse struct {
	// swagger:allOf
	shot.Shot
}

ShotResponse represents an espresso shot for this application

An espresso shot is made from coffee beans, ground at a specific setting, with a specific quantity of coffee in and out. It also has a specific shot time and water temperature.

The result of a shot can be rated and compared to the previous shot. It can also be too bitter or too sour.

swagger:response ShotResponse

type UpdateBeansByIdRequest

type UpdateBeansByIdRequest struct {
	Name       string         `json:"name"`
	RoasterId  int            `json:"roaster_id"`
	RoastDate  RoastDate      `json:"roast_date"`
	RoastLevel sql.RoastLevel `json:"roast_level"`
}

UpdateBeansByIdRequest represents the request body for updating beans with the given id swagger:model

type UpdateBeansByIdRequestParams

type UpdateBeansByIdRequestParams struct {
	// The request body for updating beans
	// in: body
	// required: true
	Body UpdateBeansByIdRequest
}

swagger:parameters updateBeansById

type UpdateRoasterByIdRequest

type UpdateRoasterByIdRequest struct {
	Name string `json:"name"`
}

UpdateRoasterByIdRequest represents the request body for updating a roaster with the given id swagger:model

type UpdateRoasterByIdRequestParams

type UpdateRoasterByIdRequestParams struct {
	// The request body for updating a roaster
	// in: body
	// required: true
	Body UpdateRoasterByIdRequest
}

swagger:parameters updateRoasterById

type UpdateSheetByIdRequest

type UpdateSheetByIdRequest struct {
	Name string `json:"name"`
}

UpdateSheetByIdRequest represents the request body for updating a sheet with the given id swagger:model

type UpdateSheetByIdRequestParams

type UpdateSheetByIdRequestParams struct {
	// The request body for updating a sheet
	// in: body
	// required: true
	Body UpdateSheetByIdRequest
}

swagger:parameters updateSheetById

type UpdateShotByIdRequest

type UpdateShotByIdRequest struct {
	SheetId                       int                               `json:"sheet_id"`
	BeansId                       int                               `json:"beans_id"`
	GrindSetting                  int                               `json:"grind_setting"`
	QuantityIn                    float64                           `json:"quantity_in"`
	QuantityOut                   float64                           `json:"quantity_out"`
	ShotTime                      time.Duration                     `json:"shot_time"`
	WaterTemperature              float64                           `json:"water_temperature"`
	Rating                        float64                           `json:"rating"`
	IsTooBitter                   bool                              `json:"is_too_bitter"`
	IsTooSour                     bool                              `json:"is_too_sour"`
	ComparaisonWithPreviousResult sql.ComparaisonWithPreviousResult `json:"comparaison_with_previous_result"`
	AdditionalNotes               string                            `json:"additional_notes"`
}

UpdateShotByIdRequest represents the request body for updating a shot with the given id swagger:model

type UpdateShotByIdRequestParams

type UpdateShotByIdRequestParams struct {
	// The request body for updating a shot
	// in: body
	// required: true
	Body UpdateShotByIdRequest
}

swagger:parameters updateShotById

Jump to

Keyboard shortcuts

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