diff --git a/cmd/frontend/UpSearch.go b/cmd/frontend/UpSearch.go index 39f75bb..bf00888 100644 --- a/cmd/frontend/UpSearch.go +++ b/cmd/frontend/UpSearch.go @@ -9,6 +9,7 @@ import ( // Enpoint that returns a list of articles given search terms in the post // request of a search form. Uses the content template. func (app *App) UpSearch(w http.ResponseWriter, req *http.Request) { + // construct search query searchTerms := req.FormValue("search") if searchTerms == "" { app.Index(w, req) @@ -17,7 +18,11 @@ func (app *App) UpSearch(w http.ResponseWriter, req *http.Request) { // get articles articles, err := app.articles.Search(searchTerms) - if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError); return; } + if err != nil { + // treat as no result + //http.Error(w, err.Error(), http.StatusInternalServerError) + return + } // convert to viewmodel articleVMs := make([]*model.ArticleViewModel, 0, len(articles))