Documentation ¶
Index ¶
- Constants
- func FuncWrapper(f restful.RouteFunction) func(req *restful.Request, resp *restful.Response)
- func GetAPIV1Action() []*httpserver.Action
- func InitActionsFunc() error
- func RegisterInitFunc(f func() error)
- func RegisterV1Action(action Action)
- func ReturnRest(resp *RestResponse)
- type Action
- type ErrorCode
- type RestResponse
- type ServerAPIResource
- type ServerErrCode
Constants ¶
const (
// PathV1 describe the prefix of version 1 http action.
PathV1 = prefix + versionV1
)
Variables ¶
This section is empty.
Functions ¶
func FuncWrapper ¶
func FuncWrapper(f restful.RouteFunction) func(req *restful.Request, resp *restful.Response)
FuncWrapper log before and after a request. If options is mater-required, then redirect the request to master node and return the data from master node.
func InitActionsFunc ¶
func InitActionsFunc() error
InitActionsFunc will call all the functions in initFunc
func RegisterInitFunc ¶
func RegisterInitFunc(f func() error)
RegisterInitFunc called by actions for registering some daemon functions and these functions will be called after flag-init and server-start
func RegisterV1Action ¶
func RegisterV1Action(action Action)
RegisterV1Action register a handler into v1 actions means all the URL of these handlers are start with PathV1
func ReturnRest ¶
func ReturnRest(resp *RestResponse)
ReturnRest do the return work according to a RestResponse
Types ¶
type RestResponse ¶
type RestResponse struct { Resp *restful.Response HTTPCode int Data interface{} ErrCode ErrorCode Message string Extra map[string]interface{} WrapFunc func([]byte) []byte }
RestResponse contains all response information need by a http handler
type ServerAPIResource ¶
type ServerAPIResource struct { ActionsV1 []*httpserver.Action DistTaskMySQL disttask.MySQL Conf *config.ServerConfig }
ServerAPIResource describe all the server api resources
func GetAPIResource ¶
func GetAPIResource() *ServerAPIResource
GetAPIResource get the standalone api resource instance
func (*ServerAPIResource) RegisterWebServer ¶
func (a *ServerAPIResource) RegisterWebServer(svr *httpserver.HTTPServer) error
RegisterWebServer register all actions in api-resource into the given http server.
type ServerErrCode ¶
type ServerErrCode int
ServerErrorCode implements the ErrorCode
const ( ServerErrOK ServerErrCode = iota ServerErrInvalidParam ServerErrRedirectFailed ServerErrEncodeJSONFailed ServerErrGetTaskFailed ServerErrGetWorkFailed )
func (ServerErrCode) String ¶
func (sec ServerErrCode) String() string
String get error string from error code