The server is hosted for free on Google Cloud.
Yes! The server instance uses http.ListenAndServe, which is concurrent.
Behind the scenes, a new goroutine is created for each connection (in
the order that connections are received).
The trie is stored in one global state managed by the server
instance. The trie is protected from race conditions by a
mutex (sync.Mutex).
The CLI uses the server's API to perform operations. For details on how to use interact with the server's REST endpoint using curl, see below.
See docs/CLI.md for info on how to install and use a command-line interface to access the API.
curl -sL https://trieapi.uk.r.appspot.com/api/v1/add/<word>
⚠️ Replace<word>with a URL-encoded word or leave it blank to add the empty string.
The server responds with
{"modified":true}or
{"modified":false}depending on whether the trie was modified. (If it wasn't, the word was already present.)
curl -sL https://trieapi.uk.r.appspot.com/api/v1/delete/<word>
⚠️ Replace<word>with a URL-encoded word or leave it blank to delete the empty string.
The server responds with
{"modified":true}or
{"modified":false}depending on whether the trie was modified. (If it wasn't, the word wasn't in the trie.)
curl -sL https://trieapi.uk.r.appspot.com/api/v1/search/<word>
⚠️ Replace<word>with a URL-encoded word or leave it blank to search for the empty string.
The server responds with
{"found":true}or
{"found":false}depending on whether the word was found in the trie.
curl -sL https://trieapi.uk.r.appspot.com/api/v1/complete/<prefix>
⚠️ Replace<prefix>with a URL-encoded prefix or leave it blank to complete the empty string.
The server responds with a JSON array of completions, for example:
["amazing", "amazon", "amaze"]curl -sL https://trieapi.uk.r.appspot.com/api/v1/display
The server responds with a JSON array of every word in the trie, for example:
["amazing", "water", "amazon", "whale", "piano", "amaze"]curl -sL https://trieapi.uk.r.appspot.com/api/v1/clear
The server responds with
{"modified":true}or
{"modified":false}depending on whether the trie was modified. (If it wasn't, the trie was already empty.)