Documentation ¶
Index ¶
- Variables
- func NewAppErr(msg string) restful.ServiceError
- func NewBadReq(msg string, args ...interface{}) restful.ServiceError
- func NewError(c CodeErr, msg string) restful.ServiceError
- func Returns(codes ...int) func(*restful.RouteBuilder)
- func Returns200(b *restful.RouteBuilder)
- func Returns201(b *restful.RouteBuilder)
- func Returns204(b *restful.RouteBuilder)
- func Returns400(b *restful.RouteBuilder)
- func Returns404(b *restful.RouteBuilder)
- func Returns409(b *restful.RouteBuilder)
- func Returns500(b *restful.RouteBuilder)
- func ReturnsE(codes ...int) func(*restful.RouteBuilder)
- func Swagger(wsContainer *restful.Container, cfg config.Swagger)
- type BaseService
- func (s *BaseService) ApiCfg() config.Api
- func (s *BaseService) BaseManager() *manager.Manager
- func (s *BaseService) Init() error
- func (s *BaseService) IsId(id string) bool
- func (s *BaseService) Mailer() email.Mailer
- func (s *BaseService) Manager() *manager.Manager
- func (s *BaseService) PassCtx() *passlib.Context
- func (s *BaseService) Register(*restful.Container)
- func (s *BaseService) Scheduler() scheduler.Scheduler
- func (s *BaseService) SetParams(r *restful.RouteBuilder, params []*restful.Parameter)
- type CodeErr
- type ErrResp
- type ServiceInterface
Constants ¶
This section is empty.
Variables ¶
View Source
var ( AppErr = NewError(CodeApp, "application error") DbErr = NewError(CodeDb, "db error") IdHexErr = NewError(CodeIdHex, "id should be bson uuid in hex form") WrongEntityErr = NewError(CodeWrongEntity, "wrong entity") DuplicateErr = NewError(CodeDuplicate, "object with the same indexes is existed") AuthReqErr = NewError(CodeAuthReq, "authorization required") AuthFailedErr = NewError(CodeAuthFailed, "authorization failed") AuthForbidErr = NewError(CodeAuthForbid, "you have no permission to this resource") )
View Source
var (
BsonIdError = validator.TextErr{Err: fmt.Errorf("should be bson uuid in hex form")}
)
Functions ¶
func Returns200 ¶
func Returns200(b *restful.RouteBuilder)
func Returns201 ¶
func Returns201(b *restful.RouteBuilder)
func Returns204 ¶
func Returns204(b *restful.RouteBuilder)
func Returns400 ¶
func Returns400(b *restful.RouteBuilder)
func Returns404 ¶
func Returns404(b *restful.RouteBuilder)
func Returns409 ¶
func Returns409(b *restful.RouteBuilder)
func Returns500 ¶
func Returns500(b *restful.RouteBuilder)
Types ¶
type BaseService ¶
type BaseService struct { Template template.Renderer Paginator *pagination.Paginator // contains filtered or unexported fields }
func (*BaseService) ApiCfg ¶
func (s *BaseService) ApiCfg() config.Api
func (*BaseService) BaseManager ¶
func (s *BaseService) BaseManager() *manager.Manager
Get the original manager, don't close it!
func (*BaseService) Init ¶
func (s *BaseService) Init() error
func (*BaseService) IsId ¶
func (s *BaseService) IsId(id string) bool
Check if id is in right format without making a copy of manager
func (*BaseService) Mailer ¶
func (s *BaseService) Mailer() email.Mailer
func (*BaseService) Manager ¶
func (s *BaseService) Manager() *manager.Manager
Get copy of the manager, don't forget to close it
func (*BaseService) PassCtx ¶
func (s *BaseService) PassCtx() *passlib.Context
func (*BaseService) Register ¶
func (s *BaseService) Register(*restful.Container)
func (*BaseService) Scheduler ¶
func (s *BaseService) Scheduler() scheduler.Scheduler
func (*BaseService) SetParams ¶
func (s *BaseService) SetParams(r *restful.RouteBuilder, params []*restful.Parameter)
set multiple params to route
type CodeErr ¶
type CodeErr int
const ( CodeApp CodeErr = 1 // just application error // error codes related to db CodeDb CodeErr = 18 CodeIdHex CodeErr = 19 CodeDuplicate CodeErr = 20 // Bad Request CodeWrongData CodeErr = 40 CodeWrongEntity CodeErr = 41 // error codes related to auth CodeAuthReq CodeErr = 60 CodeAuthFailed CodeErr = 61 CodeAuthForbid CodeErr = 62 )
type ServiceInterface ¶
type ServiceInterface interface { Init() error Register(container *restful.Container) }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.