Documentation ¶
Index ¶
- func BindFlag(config *viper.Viper, cmd *cobra.Command)
- func NewRegisterCmd(config *viper.Viper) *cobra.Command
- func ParseBroker(b IBroker) func(http.ResponseWriter, *http.Request)
- func RegisterAPI(filePath, apiSVRURI, serverURI, instanceID, instanceName string) error
- type Broker
- func (b *Broker) AcceptJSON(r *http.Request)
- func (b *Broker) InitResponse(r *http.Response) (*ResContent, error)
- func (b Broker) LogRequest(r *http.Request)
- func (b Broker) LogResponse(r *http.Response)
- func (b *Broker) ReadResponse(c *ResContent, r *http.Response) (err error)
- func (b *Broker) WrapResponse(c *ResContent, r *http.Response) error
- type DefaultBroker
- type IBroker
- type ResContent
- type ResStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseBroker ¶
func ParseBroker(b IBroker) func(http.ResponseWriter, *http.Request)
ParseBroker convert broker to http handler
func RegisterAPI ¶
RegisterAPI OpenAPI to API-SVR
Types ¶
type Broker ¶
type Broker struct { }
Broker ...
func (*Broker) AcceptJSON ¶
AcceptJSON 设置请求头 Accept: application/json
func (*Broker) InitResponse ¶
func (b *Broker) InitResponse(r *http.Response) (*ResContent, error)
InitResponse 处理常见标准错误并停供默认提示
func (*Broker) ReadResponse ¶
func (b *Broker) ReadResponse(c *ResContent, r *http.Response) (err error)
ReadResponse 读取response 内容
func (*Broker) WrapResponse ¶
func (b *Broker) WrapResponse(c *ResContent, r *http.Response) error
WrapResponse 将ResContent以json返回
type DefaultBroker ¶
type DefaultBroker struct {
Broker
}
DefaultBroker ...
func (DefaultBroker) ProcessRequest ¶
func (b DefaultBroker) ProcessRequest(r *http.Request)
ProcessRequest of DefaultBroker
func (DefaultBroker) ProcessResponse ¶
func (b DefaultBroker) ProcessResponse(r *http.Response) error
ProcessResponse of DefaultBroker
type IBroker ¶
type IBroker interface { ProcessRequest(*http.Request) ProcessResponse(*http.Response) error LogResponse(*http.Response) LogRequest(*http.Request) }
IBroker ...
type ResContent ¶
type ResContent struct { Status ResStatus `json:"status"` Result interface{} `json:"result"` }
ResContent ...
Click to show internal directories.
Click to hide internal directories.