maps-service/pkg/service/service.go

24 lines
534 B
Go
Raw Permalink Normal View History

2024-11-26 23:30:58 +00:00
package service
2024-11-26 23:28:48 +00:00
import (
"context"
"git.itzana.me/strafesnet/maps-service/pkg/api"
"git.itzana.me/strafesnet/maps-service/pkg/datastore"
2024-11-29 23:49:25 +00:00
"github.com/nats-io/nats.go"
2024-11-26 23:28:48 +00:00
)
2024-11-26 23:30:58 +00:00
type Service struct {
DB datastore.Datastore
2024-11-29 23:49:25 +00:00
Nats *nats.Conn
2024-11-26 23:28:48 +00:00
}
// NewError creates *ErrorStatusCode from error returned by handler.
//
// Used for common default response.
2024-11-26 23:30:58 +00:00
func (svc *Service) NewError(ctx context.Context, err error) *api.ErrorStatusCode {
2024-11-26 23:28:48 +00:00
return &api.ErrorStatusCode{
StatusCode: 500,
Response: api.Error{Message: err.Error()},
}
}