Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrAlreadyDefined = errors.New("AlreadyDefined")
View Source
var ErrEndpointNotFound = errors.New("EndpointNotFound")
View Source
var ErrNotExported = errors.New("NotExported")
Functions ¶
Types ¶
type ResBody ¶
type ResBody struct { ID string Ok bool Error json.RawMessage Data json.RawMessage }
func NewDataResBody ¶
func NewErrorResBody ¶
func (*ResBody) WriteResponse ¶
func (rb *ResBody) WriteResponse(code int, w http.ResponseWriter)
type ServiceRegistry ¶
type ServiceRegistry struct {
// contains filtered or unexported fields
}
ServiceRegistry 服务注册表:对内提供服务注册机制,对外提供 HTTP 接口调用。
调用点 ( Endpoint ):接口的名字,格式如下:"<mod>/<service>.<method>",如 `auth/UserService.Login`。 其中, <mod> 为模块名称,约定名称与 '/pkg/<mod>' 保持一直,如 `auth`。 <service> 为服务名称,通常命名为 `XXXXService` ,如 `UserService`。 <method> 为方法名称,如 `Login`
func NewServiceRegistry ¶
func NewServiceRegistry(prefix string) *ServiceRegistry
func (*ServiceRegistry) RegisterService ¶
func (rg *ServiceRegistry) RegisterService(modName string, ser interface{}) error
RegisterService 注册服务
modName 模块名称
service 服务实例
func (*ServiceRegistry) ServeHTTP ¶
func (rg *ServiceRegistry) ServeHTTP(w http.ResponseWriter, r *http.Request)
Click to show internal directories.
Click to hide internal directories.