Documentation ¶
Index ¶
- Constants
- func GetAPIV1Action() []*httpserver.Action
- func GetAPIV2Action() []*httpserver.Action
- func InitActionsFunc() error
- func MasterRequired(f restful.RouteFunction) func(req *restful.Request, resp *restful.Response)
- func NoLimit(f restful.RouteFunction) func(req *restful.Request, resp *restful.Response)
- func RegisterInitFunc(f func() error)
- func RegisterV1Action(action Action)
- func RegisterV2Action(action Action)
- func ReturnRest(resp *RestResponse)
- type Action
- type ErrorCode
- type ProcessType
- type RestResponse
- type ServerAPIResource
- type ServerErrCode
Constants ¶
const ( // PathV1 describe the prefix of version 1 http action. PathV1 = prefix + versionV1 // PathV2 describe the prefix of version 2 http action. PathV2 = prefix + versionV2 )
const (
// HeaderRemote define a http-header name which store the true source ip from requester.
HeaderRemote = "source_ip"
)
Variables ¶
This section is empty.
Functions ¶
func InitActionsFunc ¶
func InitActionsFunc() error
InitActionsFunc will call all the functions in initFunc
func MasterRequired ¶
func MasterRequired(f restful.RouteFunction) func(req *restful.Request, resp *restful.Response)
MasterRequired wrap the api handler and make it only available for master node.
func NoLimit ¶
func NoLimit(f restful.RouteFunction) func(req *restful.Request, resp *restful.Response)
NoLimit wrap the api handler and will process all requests.
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 RegisterV2Action ¶
func RegisterV2Action(action Action)
RegisterV2Action 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 ProcessType ¶
type ProcessType string
const ( ProcessMasterOnly ProcessType = "master_only" ProcessNoLimit ProcessType = "no_limit" )
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 ActionsV2 []*httpserver.Action Rd rd.RegisterDiscover Manager manager.Manager 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 ServerErrApplyResourceFailed ServerErrRequestTaskInfoFailed ServerErrUpdateHeartbeatFailed ServerErrReleaseResourceFailed ServerErrPreProcessFailed ServerErrRedirectFailed ServerErrEncodeJSONFailed ServerErrGetServersFailed ServerErrSendMessageFailed ServerErrUnknownMessageType )
func (ServerErrCode) String ¶
func (sec ServerErrCode) String() string
String get error string from error code