package handlers

import (
	"html/template"
	"net/http"

	"git.espin.casa/albert/cml04-falcon-printer/storage"
	"github.com/julienschmidt/httprouter"
)

type PageView struct {
}

func IndexHandler(storage storage.Storager) httprouter.Handle {
	return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
		// create view
		view := &PageView{}
		t, _ := template.ParseFiles("templates/base.html", "templates/index.html")
		if err := t.Execute(w, view); err != nil {
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}
	}
}
