Skip to content

Conversation

@rhijjawi
Copy link
Contributor

@rhijjawi rhijjawi commented May 26, 2025

Implemented a new handleSearchSuggestionsRequest HTTP handler that:

  • Accepts a query and a search engine as parameters.
  • Fetches search suggestions from predefined engines (google, duckduckgo, bing, startpage).
  • Added support for parsing JSON responses from suggestion APIs (Google-style format).
  • Extracted helper function createResponse() to parse suggestion responses cleanly.
  • Set appropriate HTTP error codes for bad requests and upstream failures.
  • Ensured results are returned as structured JSON:
{
  "query": "user input",
  "suggestions": ["suggestion1", "suggestion2", "suggestion3"]
}

For example, if

search-engine: google
suggestions: true

The search bar will use Google's autocompletion API to generate autocompletions for the query.
In the case that Startpage is the search engine, but suggestion-engine is defined, the suggestion-engine value takes precedence.

search-engine: startpage
suggestions: true
suggestion-engine: google

To be entirely clear:

./glance.go now contains the rough equivalent of a proxy. Its sole purpose is to ignore Startpage's CORS restriction on who can make requests to their suggestion endpoint, this is within their Terms of Use.
This seems like the best solution at the moment, it works very well. I have not yet run into issues regarding rate-limiting, nor do I predict any issues.

@rhijjawi rhijjawi changed the title Add search suggestions feature with multiple engines and UI enhancements Add search suggestions feature with separated search engine and suggestion engine. May 26, 2025
@rhijjawi
Copy link
Contributor Author

Issue #700 - Feature Request Implementation

rhijjawi added 2 commits May 27, 2025 00:51
… shortened function & improved code readability.
…o allow arrow keys to select an entry and press enter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant