feat: make api more useful for usage in search bars and the like
This commit is contained in:
parent
1ff513ebae
commit
157012b9f5
1 changed files with 13 additions and 2 deletions
15
main.go
15
main.go
|
|
@ -103,8 +103,19 @@ func (h *stopInfoHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
if r.FormValue("exact") != "true" {
|
||||
searchQuery = "%" + searchQuery + "%"
|
||||
var searchQueries = strings.Split(searchQuery, " ")
|
||||
|
||||
for i, query := range searchQueries {
|
||||
if i == 0 {
|
||||
// Parse whether result shall be exact
|
||||
if r.FormValue("contains") != "true" {
|
||||
searchQueries[0] = "%" + query + "%"
|
||||
} else {
|
||||
searchQueries[0] = query + "%"
|
||||
}
|
||||
} else {
|
||||
searchQueries[i] = "%" + query + "%"
|
||||
}
|
||||
}
|
||||
|
||||
var longDistance pgtype.Bool
|
||||
|
|
|
|||
Loading…
Reference in a new issue