Return help message for / request on HTTP service

pull/69/head
Thomas Buckley-Houston 2018-06-18 20:00:29 +08:00
rodzic cddd3ca173
commit ea53e6b467
1 zmienionych plików z 16 dodań i 0 usunięć

Wyświetl plik

@ -58,7 +58,23 @@ func (h *slashFix) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
func handleHTTPServerRequest(w http.ResponseWriter, r *http.Request) {
var message string
urlForBrowsh, _ := url.PathUnescape(strings.TrimPrefix(r.URL.Path, "/"))
if strings.TrimSpace(urlForBrowsh) == "" {
if (strings.Contains(r.Host, "text.")) {
message = "Welcome to the Browsh plain text client.\n" +
"You can use it by appending URLs like this;\n" +
"http://html.brow.sh/https://www.brow.sh"
} else {
message = "<html>" +
"Welcome to the Browsh HTML web client.<br />" +
"Type a URL after 'html.brow.sh' in your URL bar, eg;<br />" +
"<a href=\"http://html.brow.sh/https://www.brow.sh\">http://html.brow.sh/https://www.brow.sh</a><br />" +
"</html>"
}
io.WriteString(w, message)
return
}
rawTextRequestID := pseudoUUID()
mode := getRawTextMode(r)
sendMessageToWebExtension(