Skip to content

Commit

Permalink
Added unsued filter func and new image for README.
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno.chavez committed Jun 4, 2018
1 parent 6c895c1 commit a0bdc5f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Binary file modified assets/images/browserImage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func SearchHandler(w http.ResponseWriter, r *http.Request) {
case "GET":
query := mux.Vars(r)
wordToSearch := query["word"]

matched := false
quotesMatched := make(database.QuoteSlice, 0)

Expand Down Expand Up @@ -80,6 +79,7 @@ func SearchHandler(w http.ResponseWriter, r *http.Request) {
}
}
}

if matched {
w.Header().Set("Content-Type", "application/json")
filteredSLice, _ := json.MarshalIndent(quotesMatched, "", "")
Expand Down
24 changes: 23 additions & 1 deletion lib/lib.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Package lib contains various functions that may be useful for more than one part of the API.
package lib

import "encoding/json"
import (
"encoding/json"
)

/*
//BadRequest returns a ready to use badrequest text, not used for now
Expand All @@ -17,3 +19,23 @@ func NotFound(notFoundWord string) []byte {

return notFoundJSON
}

// Filter returns a slice with all the words of a QuoteSlice after been filtered.
/*func Filter(filters []string, slice database.QuoteSlice) []string {
var count int
filteredWords := make([]string, 0)
for _, quote := range slice {
s := strings.Split(quote.Quote, " ")
for _, word := range s {
filtered := word
for count < len(filters) {
filtered = strings.Split(filtered, filters[count])[0]
count++
}
count = 0
filteredWords = append(filteredWords, filtered)
}
}
return filteredWords
}*/

0 comments on commit a0bdc5f

Please sign in to comment.