package handlers

import (
	"encoding/json"
	"lash"
	"lash/internal/errx"
	"net/http"
)

type FileData struct {
	Contents []byte
}

type ValidateRequest struct {
	Token string
}

func (h FileData) APIHandler(w http.ResponseWriter, r *http.Request) {
	decoder := json.NewDecoder(r.Body)
	var t ValidateRequest
	err := decoder.Decode(&t)
	if err != nil {
		errx.FatalPerror(err)
	}

	if t.Token == lash.Token {
		errx.Log("Got token")
	} else {
		errx.Log("No Token")
	}
}

func (h FileData) DownloadHandler(w http.ResponseWriter, r *http.Request) {
	w.Write(h.Contents)
}
