Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeDeleteMessageRequest(_ context.Context, r *http.Request) (request interface{}, err error)
- func DecodeDeleteMessageResponse(_ context.Context, r *http.Response) (interface{}, error)
- func DecodeGetMessageRequest(_ context.Context, r *http.Request) (request interface{}, err error)
- func DecodeGetMessageResponse(_ context.Context, r *http.Response) (interface{}, error)
- func DecodePostMessageRequest(_ context.Context, r *http.Request) (request interface{}, err error)
- func DecodePostMessageResponse(_ context.Context, r *http.Response) (interface{}, error)
- func DecodePutMessageRequest(_ context.Context, r *http.Request) (request interface{}, err error)
- func DecodePutMessageResponse(_ context.Context, r *http.Response) (interface{}, error)
- func DecodeRebootRequest(_ context.Context, r *http.Request) (request interface{}, err error)
- func DecodeRebootResponse(_ context.Context, r *http.Response) (interface{}, error)
- func DecodeUnlockRequest(_ context.Context, r *http.Request) (request interface{}, err error)
- func DecodeUnlockResponse(_ context.Context, r *http.Response) (interface{}, error)
- func EncodeDeleteMessageRequest(ctx context.Context, req *http.Request, request interface{}) error
- func EncodeGetMessageRequest(ctx context.Context, req *http.Request, request interface{}) error
- func EncodePostMessageRequest(ctx context.Context, req *http.Request, request interface{}) error
- func EncodePutMessageRequest(ctx context.Context, req *http.Request, request interface{}) error
- func EncodeRebootRequest(ctx context.Context, req *http.Request, request interface{}) error
- func EncodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error
- func EncodeUnlockRequest(ctx context.Context, req *http.Request, request interface{}) error
- func MakeDeleteMessageEndpoint(s IService) endpoint.Endpoint
- func MakeGetMessageEndpoint(s IService) endpoint.Endpoint
- func MakeHTTPHandler(s IService, logger log.Logger) http.Handler
- func MakePostMessageEndpoint(s IService) endpoint.Endpoint
- func MakePutMessageEndpoint(s IService) endpoint.Endpoint
- func MakeRebootEndpoint(s IService) endpoint.Endpoint
- func MakeUnlockEndpoint(s IService) endpoint.Endpoint
- type Backend
- type Database
- type Endpoints
- func (e Endpoints) DeleteMessage(ctx context.Context, id int) error
- func (e Endpoints) GetMessage(ctx context.Context, id int) (Message, error)
- func (e Endpoints) PostMessage(ctx context.Context, m Message) error
- func (e Endpoints) PutMessage(ctx context.Context, id int, m Message) error
- func (e Endpoints) Reboot(ctx context.Context) error
- func (e Endpoints) Unlock(ctx context.Context) error
- type IBackend
- type IService
- type Message
- type Middleware
- type Service
- func (s *Service) DeleteMessage(ctx context.Context, id int) error
- func (s *Service) GetMessage(ctx context.Context, id int) (Message, error)
- func (s *Service) PostMessage(ctx context.Context, m Message) error
- func (s *Service) PutMessage(ctx context.Context, id int, m Message) error
- func (s *Service) Reboot(ctx context.Context) error
- func (s *Service) Unlock(ctx context.Context) error
Constants ¶
View Source
const ( CAN_ID_MIN = 0x0 CAN_ID_MAX = 0x1fffffff )
Variables ¶
View Source
var ( ErrBackendPortOpen = errors.New("Backend: port open error") ErrBackendPortClose = errors.New("Backend: port close error") ErrBackendPortFlush = errors.New("Backend: port flush error") ErrBackendSlcanInit = errors.New("Backend: SLCAN initialise error") ErrBackendInvalidID = errors.New("Backend: invalid ID") ErrBackendInvalidData = errors.New("Backend: invalid data") ErrBackendInvalidFrame = errors.New("Backend: invalid frame") ErrBackendReboot = errors.New("Backend: reboot failed") ErrBackendOnhold = errors.New("Backend: on hold") ErrBackendMsgQueue = errors.New("Backend: message queue ping failed") )
View Source
var ( ErrDatabaseAlreadyExists = errors.New("Database: already exists") ErrDatabaseNotFound = errors.New("Database: request not found") )
View Source
var (
ErrServiceInvalidID = errors.New("Service: invalid id")
)
View Source
var ( // ErrTransportBadRouting is returned when an expected path variable is missing. // It always indicates programmer error. ErrTransportBadRouting = errors.New("Transport: bad routing") )
Functions ¶
func DecodeGetMessageRequest ¶
func DecodePutMessageRequest ¶
func DecodeRebootRequest ¶
func DecodeRebootResponse ¶
func DecodeUnlockRequest ¶
func DecodeUnlockResponse ¶
func EncodeGetMessageRequest ¶
func EncodePutMessageRequest ¶
func EncodeRebootRequest ¶
func EncodeResponse ¶
func EncodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error
func EncodeUnlockRequest ¶
func MakeGetMessageEndpoint ¶
func MakePostMessageEndpoint ¶
func MakePutMessageEndpoint ¶
func MakeRebootEndpoint ¶
func MakeUnlockEndpoint ¶
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
func (*Backend) GetMessage ¶
func (*Backend) PostMessage ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func (*Database) DeleteData ¶
type Endpoints ¶
type Endpoints struct { GetMessageEndpoint endpoint.Endpoint PostMessageEndpoint endpoint.Endpoint PutMessageEndpoint endpoint.Endpoint DeleteMessageEndpoint endpoint.Endpoint RebootEndpoint endpoint.Endpoint UnlockEndpoint endpoint.Endpoint }
func MakeClientEndpoints ¶
MakeClientEndpoints returns an Endpoints struct where each endpoint invokes the corresponding method on the remote instance, via a transport/http.Client.
func MakeServerEndpoints ¶
func (Endpoints) DeleteMessage ¶
func (Endpoints) GetMessage ¶
struct Endpoints implements interface IService. Primarily useful in a client.
func (Endpoints) PutMessage ¶
type IBackend ¶
type IBackend interface { Handler(port string, baud int, url string) error GetMessage(id int) error PostMessage(m Message) error Reboot() error Unlock() error }
func NewBackend ¶
func NewBackend() IBackend
type IService ¶
type IService interface { GetMessage(ctx context.Context, id int) (Message, error) PostMessage(ctx context.Context, m Message) error PutMessage(ctx context.Context, id int, m Message) error DeleteMessage(ctx context.Context, id int) error Reboot(ctx context.Context) error Unlock(ctx context.Context) error }
func NewService ¶
func NewService() IService
type Middleware ¶
Middleware describes a service (as opposed to endpoint) middleware.
func BackendMiddleware ¶
func BackendMiddleware(backend IBackend) Middleware
func LoggingMiddleware ¶
func LoggingMiddleware(logger log.Logger) Middleware
type Service ¶
type Service struct{}
func (*Service) DeleteMessage ¶
DeleteMessage godoc
@Summary Remove CAN message @Schemes @Description Remove CAN message by specifying CAN ID @Tags SLCAN @Param int path int true "CAN ID" minimum(0) maximum(536870911) @Accept json @Produce json @Success 200 @Failure 400 @Failure 404 @Failure 500 @Router /slcan/{id} [delete]
func (*Service) GetMessage ¶
GetMessage godoc
@Summary Retrieve CAN message @Schemes @Description Retrieve CAN message by specifying CAN ID @Tags SLCAN @Param int path int true "CAN ID" minimum(0) maximum(536870911) @Accept json @Produce json @Success 200 {array} slcansvc.Message @Failure 400 @Failure 404 @Failure 500 @Router /slcan/{id} [get]
func (*Service) PostMessage ¶
PostMessage godoc
@Summary Add new CAN message @Schemes @Description Add new CAN message by specifying CAN ID and data @Tags SLCAN @Param array body slcansvc.Message false "CAN Message" @Accept json @Produce json @Success 200 @Failure 400 @Failure 404 @Failure 500 @Router /slcan [post]
func (*Service) PutMessage ¶
PutMessage godoc
@Summary Update existing CAN message @Schemes @Description Update existing CAN message by specifying CAN ID and data @Tags SLCAN @Param array body slcansvc.Message false "CAN Message" @Accept json @Produce json @Success 200 @Failure 400 @Failure 404 @Failure 500 @Router /slcan/{id} [put]
func (*Service) Reboot ¶
Reboot godoc
@Summary Reboot SLCAN device @Schemes @Description Reboot SLCAN device for firmware update @Tags SLCAN @Accept json @Produce json @Success 200 @Failure 400 @Failure 404 @Failure 500 @Router /slcan/reboot [post]
Source Files ¶
Click to show internal directories.
Click to hide internal directories.