package example_chat_test

import (
	"context"
	"log"

	"git.ali33.ru/fcg-xvii/rest"
	"git.ali33.ru/fcg-xvii/rest/example_chat/users"
	"git.ali33.ru/fcg-xvii/rest/rest_websocket"
)

func NewApplication(ctx context.Context) *Application {
	rApp := rest_websocket.NewApplication(ctx)
	return &Application{
		Application: rApp,
	}
}

type Application struct {
	*rest_websocket.Application
}

func (s *Application) Executer(r rest.IRequest) (rest.IExecuter, bool) {
	log.Println("COMMAND", r.Command())
	switch r.Command() {
	case "/users/register":
		return &users.Register{}, true
	}
	return nil, false
}
