Documentation ¶
Index ¶
- func MakeEndpointCreate(s Service) endpoint.Endpoint
- func MakeEndpointDeleteByID(s Service) endpoint.Endpoint
- func MakeEndpointGetAll(s Service) endpoint.Endpoint
- func MakeEndpointGetByID(s Service) endpoint.Endpoint
- func MakeEndpointUpdate(s Service) endpoint.Endpoint
- func NewService(repo SpaceShipRepository, logger log.Logger) *service
- func RegisterRoutes(router *httprouter.Router, s Service)
- type CreateRequestModel
- type CreateResponseModel
- type DeleteByIDRequestModel
- type DeleteByIDResponseModel
- type GetAllRequestModel
- type GetAllResponseModel
- type GetByIDRequestModel
- type GetByIDResponseModel
- type Service
- type SpaceShipRepository
- type UpdateRequestModel
- type UpdateResponseModel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeEndpointCreate ¶
@BasePath / Create godoc @Description Create new spaceship. @Tags Spaceship @Accept json @Produce json @Param request body createRequest true "Request body (JSON)" @Success 201 @Failure 500 @Router /spaceship [post]
func MakeEndpointDeleteByID ¶
@BasePath / Delete godoc @Description Delete existing spaceship by a specific ID. @Tags Spaceship @Produce json @Param id path string true "Spaceship ID (integer)" @Success 200 @Failure 400 @Failure 500 @Router /spaceship/{id} [delete]
func MakeEndpointGetAll ¶
@BasePath / GetAll godoc @Description Get all spaceships. @Tags Spaceship @Produce json @Success 200 @Failure 500 @Router /spaceship [get]
func MakeEndpointGetByID ¶
@BasePath / GetByID godoc @Description Fetch existing spaceship by a specific ID. @Tags Spaceship @Produce json @Param id path string true "Spaceship ID (integer)" @Success 200 @Failure 400 @Failure 500 @Router /spaceship/{id} [get]
func MakeEndpointUpdate ¶
@BasePath / Update godoc @Description Update existing spaceship by a specific ID. @Tags Spaceship @Accept json @Produce json @Param id path string true "Spaceship ID (integer)" @Param request body updateRequest true "Request body (JSON)" @Success 200 @Failure 400 @Failure 500 @Router /spaceship/{id} [patch]
func NewService ¶
func NewService(repo SpaceShipRepository, logger log.Logger) *service
func RegisterRoutes ¶
func RegisterRoutes(router *httprouter.Router, s Service)
Types ¶
type CreateRequestModel ¶
type CreateRequestModel struct { Name string Class string Crew int64 Image string Value float64 Status string Armaments []armamentReqModel }
func (CreateRequestModel) ToEntity ¶
func (r CreateRequestModel) ToEntity() entity.SpaceShip
type CreateResponseModel ¶
type CreateResponseModel struct {
Success bool
}
type DeleteByIDRequestModel ¶
type DeleteByIDRequestModel struct {
ID int64
}
type DeleteByIDResponseModel ¶
type DeleteByIDResponseModel struct {
Success bool
}
type GetAllRequestModel ¶
func (GetAllRequestModel) ToEntity ¶
func (r GetAllRequestModel) ToEntity() entity.SpaceShip
type GetAllResponseModel ¶
type GetByIDRequestModel ¶
type GetByIDRequestModel struct {
ID int64
}
type GetByIDResponseModel ¶
type Service ¶
type Service interface { Create(ctx context.Context, req entity.SpaceShip) error GetByID(ctx context.Context, id int64) (entity.SpaceShip, error) Update(ctx context.Context, id int64, req entity.SpaceShip) error Delete(ctx context.Context, id int64) error GetAll(ctx context.Context, req entity.SpaceShip) ([]entity.SpaceShip, error) }
type SpaceShipRepository ¶
type SpaceShipRepository interface { Insert(ctx context.Context, req entity.SpaceShip) error GetByID(ctx context.Context, id int64) (entity.SpaceShip, error) Update(ctx context.Context, id int64, req entity.SpaceShip) error Delete(ctx context.Context, id int64) error GetAll(ctx context.Context, req entity.SpaceShip) ([]entity.SpaceShip, error) DeleteArmaments(ctx context.Context, spaceshipID int64) error }
type UpdateRequestModel ¶
type UpdateRequestModel struct { ID int64 Name string Class string Crew int64 Image string Value float64 Status string Armaments []armamentReqModel }
func (UpdateRequestModel) ToEntity ¶
func (r UpdateRequestModel) ToEntity() entity.SpaceShip
type UpdateResponseModel ¶
type UpdateResponseModel struct {
Success bool
}