package controller

import (
	"net/http"

	"git.markbailey.dev/cerbervs/ptpp/app/session"
	"git.markbailey.dev/cerbervs/ptpp/lib/logger"

	"git.markbailey.dev/cerbervs/ptpp/lib/database"
)

type IController interface {
	Get(w http.ResponseWriter, r *http.Request) error
	Head(w http.ResponseWriter, r *http.Request) error
	Options(w http.ResponseWriter, r *http.Request) error
	Trace(w http.ResponseWriter, r *http.Request) error
	Put(w http.ResponseWriter, r *http.Request) error
	Delete(w http.ResponseWriter, r *http.Request) error
	Post(w http.ResponseWriter, r *http.Request) error
	Patch(w http.ResponseWriter, r *http.Request) error
	Connect(w http.ResponseWriter, r *http.Request) error
	Init(session.IManager, database.IDB, logger.ILogger, IControllerCtx) IController
}

type Controller struct {
	Session session.IManager
	Db      database.IDB
	Logger  logger.ILogger
	Ctx     IControllerCtx
}

func (c Controller) Init(s session.IManager, d database.IDB, l logger.ILogger, ctx IControllerCtx) IController {
	return nil
}

func (c Controller) Get(w http.ResponseWriter, _ *http.Request) (_ error) {
	if _, err := w.Write([]byte("not implemented")); err != nil {
		c.Logger.Error(c.Logger.Wrap(err, "Error writing response"))
		return err
	}
	return nil
}

func (c Controller) Head(w http.ResponseWriter, _ *http.Request) (_ error) {
	if _, err := w.Write([]byte("not implemented")); err != nil {
		c.Logger.Error(c.Logger.Wrap(err, "Error writing response"))
		return err
	}
	return nil
}

func (c Controller) Options(w http.ResponseWriter, _ *http.Request) (_ error) {
	if _, err := w.Write([]byte("not implemented")); err != nil {
		c.Logger.Error(c.Logger.Wrap(err, "Error writing response"))
		return err
	}
	return nil
}

func (c Controller) Trace(w http.ResponseWriter, _ *http.Request) (_ error) {
	if _, err := w.Write([]byte("not implemented")); err != nil {
		c.Logger.Error(c.Logger.Wrap(err, "Error writing response"))
		return err
	}
	return nil
}

func (c Controller) Put(w http.ResponseWriter, _ *http.Request) (_ error) {
	if _, err := w.Write([]byte("not implemented")); err != nil {
		c.Logger.Error(c.Logger.Wrap(err, "Error writing response"))
		return err
	}
	return nil
}

func (c Controller) Delete(w http.ResponseWriter, _ *http.Request) (_ error) {
	if _, err := w.Write([]byte("not implemented")); err != nil {
		c.Logger.Error(c.Logger.Wrap(err, "Error writing response"))
		return err
	}
	return nil
}

func (c Controller) Post(w http.ResponseWriter, _ *http.Request) (_ error) {
	if _, err := w.Write([]byte("not implemented")); err != nil {
		c.Logger.Error(c.Logger.Wrap(err, "Error writing response"))
		return err
	}
	return nil
}

func (c Controller) Patch(w http.ResponseWriter, _ *http.Request) (_ error) {
	if _, err := w.Write([]byte("not implemented")); err != nil {
		c.Logger.Error(c.Logger.Wrap(err, "Error writing response"))
		return err
	}
	return nil
}

func (c Controller) Connect(w http.ResponseWriter, _ *http.Request) (_ error) {
	if _, err := w.Write([]byte("not implemented")); err != nil {
		c.Logger.Error(c.Logger.Wrap(err, "Error writing response"))
		return err
	}
	return nil
}
