summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authornavanchauhan <navanchauhan@gmail.com>2022-10-17 00:57:17 -0600
committernavanchauhan <navanchauhan@gmail.com>2022-10-17 00:57:17 -0600
commitb30f1b96ff122e2f1a66f9d2d63de881d2e6140e (patch)
tree94c9c41258ca2e75e9e0137e51bbfd5aebc3e41d /main.go
parentca5c3e37b231baac8b39aa6f789da29ac6dc501f (diff)
began individual document
Diffstat (limited to 'main.go')
-rw-r--r--main.go32
1 files changed, 32 insertions, 0 deletions
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)