File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package search
22
33import (
4+ "encoding/base64"
45 "encoding/json"
56 "fmt"
6- "io"
77 "net/http"
88
99 "github.com/moov-io/ach-web-viewer/pkg/filelist"
@@ -70,15 +70,26 @@ func (c *controller) index(w http.ResponseWriter, r *http.Request) {
7070 }
7171}
7272
73+ type searchRequest struct {
74+ Query string `json:"query"`
75+ }
76+
7377func (c * controller ) search (w http.ResponseWriter , r * http.Request ) {
7478 ctx , span := telemetry .StartSpan (r .Context (), "api-search" )
7579 defer span .End ()
7680
77- query , err := io .ReadAll (r .Body )
81+ var req searchRequest
82+ err := json .NewDecoder (r .Body ).Decode (& req )
83+ if err != nil {
84+ c .errorResponse (w , fmt .Errorf ("reading search request: %v" , err ))
85+ return
86+ }
87+ query , err := base64 .StdEncoding .DecodeString (req .Query )
7888 if err != nil {
79- c .errorResponse (w , fmt .Errorf ("problem reading search body: %v" , err ))
89+ c .errorResponse (w , fmt .Errorf ("problem decoding query body: %v" , err ))
8090 return
8191 }
92+ fmt .Printf ("\n \n %s\n " , string (query ))
8293
8394 options , err := filelist .ReadListOptions (r )
8495 if err != nil {
Original file line number Diff line number Diff line change @@ -291,6 +291,10 @@ window.onload = function () {
291291 } ) ;
292292} ;
293293
294+ function encodeSQLToBase64 ( sql ) {
295+ return btoa ( sql ) ;
296+ }
297+
294298function performSearch ( body ) {
295299 const currentParams = new URLSearchParams ( window . location . search ) ;
296300 const queryParams = new URLSearchParams ( ) ;
@@ -314,7 +318,9 @@ function performSearch(body) {
314318 headers : {
315319 "Content-Type" : "text/plain" ,
316320 } ,
317- body : body ,
321+ body : JSON . stringify ( {
322+ query : encodeSQLToBase64 ( body ) ,
323+ } ) ,
318324 } )
319325 . then ( ( response ) => response . json ( ) )
320326 . then ( ( data ) => {
You can’t perform that action at this time.
0 commit comments