From b30f1b96ff122e2f1a66f9d2d63de881d2e6140e Mon Sep 17 00:00:00 2001 From: navanchauhan Date: Mon, 17 Oct 2022 00:57:17 -0600 Subject: began individual document --- main.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'main.go') diff --git a/main.go b/main.go index 535e575..2a2f4d9 100644 --- a/main.go +++ b/main.go @@ -30,6 +30,10 @@ type SearchResponse struct { NumPages int } +type DocumentResponse struct { + SearchResults interface{} +} + func pageCount(total int, perPage int) int { return int(math.Ceil(float64(total) / float64(perPage))) } @@ -73,12 +77,40 @@ func main() { // v2.0 UI searchResultsTemplate2 := template.Must(template.New("search_results.html").Funcs(funcMap).ParseFiles("templates/search_results.html")) + //documentDetailsTemplate2 := template.Must(template.New("document_details.html").Funcs(funcMap).ParseFiles("templates/document_details.html")) + documentDetailsTemplate2 := template.Must(template.ParseFiles("templates/document_details.html")) if err != nil { fmt.Println("Error parsing template") os.Exit(1) } + http.HandleFunc("/dbentry", func(w http.ResponseWriter, r *http.Request) { + r.ParseForm() + fmt.Println(r.Form) + var res interface{} + var documentID string = r.FormValue("id") + if r.Form["id"] != nil { + index.GetDocument(documentID, &meilisearch.DocumentQuery{ + Fields: []string{ + "title", + "applicant", + "decision", + "decision_date", + "id", + "predicates", + "submission_date", + }}, &res) + fmt.Println(res) + documentDetailsTemplate2.Execute(w, DocumentResponse{ + SearchResults: res, + }) + } else { + fmt.Println("No ID provided") + } + + }) + http.HandleFunc("/search", func(w http.ResponseWriter, r *http.Request) { r.ParseForm() fmt.Println(r.Form) -- cgit v1.2.3