package rest

type IApplication interface {
	Executer(r IRequest) (IExecuter, bool)
}

///////////////////////////////////////////////

type IValidator interface {
	Validate(r IRequest) IResponse
}

type IExecuter interface {
	Execute(r IRequest) IResponse
}

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 IRequest) IResponse {
	return s.validator.Validate(r)
}

func (s *Command) Execute(r IRequest) IResponse {
	return s.executer.Execute(r)
}

///////////////////////////////////////////////

func NewValidator(method func(r IRequest) IResponse) *Validator {
	return &Validator{
		method,
	}
}

type Validator struct {
	method func(r IRequest) IResponse
}

func (s *Validator) Validate(r IRequest) IResponse {
	return s.method(r)
}

///////////////////////////////////////////////

func NewExecuter(method func(r IRequest) IResponse) *Executer {
	return &Executer{
		method,
	}
}

type Executer struct {
	method func(r IRequest) IResponse
}

func (s *Executer) Execute(r IRequest) IResponse {
	return s.method(r)
}
