package routing

import (
	"net/http"

	"gitlab.com/tpeetz-kontor/kontor-go/cmd/pkg/context/comic/responses"
	"gitlab.com/tpeetz-kontor/kontor-go/cmd/pkg/infrastructure/app"
	responseFactory "gitlab.com/tpeetz-kontor/kontor-go/cmd/pkg/infrastructure/response"
)

// Handler is the http.Handler for this request
type Handler struct {
	app *app.Application
}

// NewHandler will create a new Handler to handle this request
func NewHandler(app *app.Application) *Handler {
	return &Handler{app}
}

// Handle will handle the incoming request
func (handler *Handler) ComicList(response http.ResponseWriter, request *http.Request) {
	handler.app.Logger.Info("Ping Handler Dispatched.")

	responseFactory.Send(
		response,
		http.StatusOK,
		&responses.ComicList{
			Comics: []responses.Comic{{ID: "123", Title: "Comic1"}, {ID: "123", Title: "Comic1"}},
		},
		handler.app.Config.HTTP.Content,
	)
}
