micro.go 631 B

12345678910111213141516171819202122232425262728293031323334
  1. package micro
  2. import (
  3. "context"
  4. )
  5. type (
  6. HandleOptions struct {
  7. HttpMethod string
  8. DisableRpc bool
  9. DisableHttp bool
  10. }
  11. HandleOption func(o *HandleOptions)
  12. HandleFunc func(ctx Context) (err error)
  13. Application interface {
  14. Handle(method string, cb HandleFunc) (err error) //注册一个处理器
  15. NewRequest(service, method string, payload interface{}) (err error) //创建一个rpc请求
  16. }
  17. Server interface {
  18. Start(ctx context.Context) (err error)
  19. Stop() (err error)
  20. }
  21. )
  22. func WithHttpMethod(method string) HandleOption {
  23. return func(o *HandleOptions) {
  24. o.HttpMethod = method
  25. }
  26. }