package rest type IValidator interface { Validate(r *Request) *Response } type IExecuter interface { Execute(r *Request) *Response } type ICommand interface { IValidator IExecuter } /////////////////////////////////////////////// func NewCommand(validator IValidator, executer IExecuter) *Command { return &Command{ validator, executer, } } type Command struct { validator IValidator executer IExecuter } func (s *Command) Validate(r *Request) *Response { return s.validator.Validate(r) } func (s *Command) Execute(r *Request) *Response { return s.executer.Execute(r) } /////////////////////////////////////////////// func NewValidator(method func(r *Request) *Response) *Validator { return &Validator{ method, } } type Validator struct { method func(r *Request) *Response } func (s *Validator) Validate(r *Request) *Response { return s.method(r) } /////////////////////////////////////////////// func NewExecuter(method func(r *Request) *Response) *Executer { return &Executer{ method, } } type Executer struct { method func(r *Request) *Response } func (s *Executer) Execute(r *Request) *Response { return s.method(r) }