Skip to content

Commit

Permalink
Return help message for / request on HTTP service
Browse files Browse the repository at this point in the history
  • Loading branch information
tombh committed Jun 18, 2018
1 parent cddd3ca commit ea53e6b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions interfacer/src/browsh/raw_text_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit ea53e6b

Please sign in to comment.