diff options
author | navanchauhan <navanchauhan@gmail.com> | 2022-10-17 00:57:17 -0600 |
---|---|---|
committer | navanchauhan <navanchauhan@gmail.com> | 2022-10-17 00:57:17 -0600 |
commit | b30f1b96ff122e2f1a66f9d2d63de881d2e6140e (patch) | |
tree | 94c9c41258ca2e75e9e0137e51bbfd5aebc3e41d /main.go | |
parent | ca5c3e37b231baac8b39aa6f789da29ac6dc501f (diff) |
began individual document
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -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) |