1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- 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)
- }
|