diff --git a/README.md b/README.md index 4e8b857..5fe7e9b 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ * [Exposing services](#exposing-services) * [Sharing files](#sharing-files) * [`echo`](#echo) +* [`d`](#d) * [Finding my IP](#finding-my-ip) ## Exposing services @@ -112,6 +113,10 @@ Content-Type: application/json {"a":42} ``` +## `d` + +Embed a page in the URL itself, in its client-only side. [Example](https://srv.us/d#%3Ch1%3EDemo%3C/h1%3E), [original idea](https://news.ycombinator.com/item?id=39905866). + ## Finding my IP Please take a look at [ident.me](https://api.ident.me). diff --git a/backend/main.go b/backend/main.go index a807563..9978a2d 100644 --- a/backend/main.go +++ b/backend/main.go @@ -355,6 +355,11 @@ func (s *server) serveRoot(https *tls.Conn) error { } _, _ = https.Write([]byte(fmt.Sprintf("HTTP/1.1 200 OK\r\nContent-Type: %s\r\n\r\n", ct))) _, _ = io.Copy(https, req.Body) + } else if req.URL.Path == "/d" { + defer func() { + _ = req.Body.Close() + }() + _, _ = https.Write([]byte("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n")) } else if req.Method == "POST" { defer func() { _ = req.Body.Close()