func ListDocuments(resp http.ResponseWriter, req *http.Request, ps httprouter.Params) {
	documents := store.List()
	log.Info().Msg("Loading all documents from store")
	raw, err := json.Marshal(documents)
	if err != nil {
		log.Error().Err(err).Msg("Failed to serialize documents to JSON")
		resp.WriteHeader(http.StatusInternalServerError)
	} else {
		resp.Header().Add("Content-Type", "application/json")
		resp.Write(raw)
	}
}
ListDocuments returns a list of all documents
package web
import (
	"encoding/json"
	"fmt"
	"net/http"
	"net/url"
	"path"
	"strconv"
	"strings"
	"github.com/gobuffalo/packr"
	"github.com/julienschmidt/httprouter"
	"github.com/rs/zerolog/log"
	"archiscribe/lib"
)
var taskChan = make(chan lib.TaskDefinition)
var store *lib.DocumentStore
type APIError struct {
	Err  error `json:"error"`
	Code int   `json:"code"`
}
func writeAPIError(err error, code int, w http.ResponseWriter) {
	apiErr := APIError{
		Err:  err,
		Code: code}
	out, _ := json.MarshalIndent(apiErr, "", "  ")
	w.WriteHeader(code)
	w.Header().Add("Content-Type", "application/json")
	w.Write(out)
}
func SubmitDocument(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
	var task lib.TaskDefinition
	err := json.NewDecoder(r.Body).Decode(&task)
	task.ResultChan = make(chan lib.SubmitResult)
	defer close(task.ResultChan)
	if err != nil {
		log.Error().
			Err(err).
			Str("documentId", task.Document.Identifier).
			Msg("Could not decode submitted document")
		writeAPIError(err, 500, w)
	} else {
		log.Info().
			Bool("isUpdate", r.Method == "POST").
			Int("numTranscriptions", len(task.Document.Lines)).
			Str("documentId", task.Document.Identifier).
			Msg("Received transcription")
		stored, err := store.Save(task.Document, task.Author, task.Email, task.Comment)
		if err != nil {
			log.Error().
				Err(err).
				Str("documentId", task.Document.Identifier).
				Msg("Error storing document")
			writeAPIError(err, 500, w)
			return
		}
		js, _ := json.MarshalIndent(stored, "", "  ")
		w.WriteHeader(http.StatusOK)
		w.Header().Add("Content-Type", "application/json")
		w.Write(js)
	}
}
func ProduceLines(resp http.ResponseWriter, req *http.Request, ps httprouter.Params) {
	year, _ := strconv.Atoi(ps.ByName("year"))
	taskSize, _ := strconv.Atoi(req.URL.Query().Get("taskSize"))
	lineProd, err := newLineProducer(resp, taskSize, year)
	if err != nil {
		log.Error().Err(err).Msg("Failed to create line producer")
		resp.WriteHeader(http.StatusInternalServerError)
	} else {
		lineProd.produceLines()
	}
}