summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/labstack/echo/cookbook/http2/server.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-02-18 23:00:46 +0100
committerWim <wim@42.be>2017-02-18 23:11:48 +0100
commit930b639cc9cd2d2873302f30303378c0e53816a8 (patch)
tree8cd3f1d464fb5d4e5607fe16255c35a31a9d8b62 /vendor/github.com/labstack/echo/cookbook/http2/server.go
parent58483ea70c2c99a352592c5e50686fb03985650e (diff)
downloadmatterbridge-msglm-930b639cc9cd2d2873302f30303378c0e53816a8.tar.gz
matterbridge-msglm-930b639cc9cd2d2873302f30303378c0e53816a8.tar.bz2
matterbridge-msglm-930b639cc9cd2d2873302f30303378c0e53816a8.zip
Update vendor
Diffstat (limited to 'vendor/github.com/labstack/echo/cookbook/http2/server.go')
-rw-r--r--vendor/github.com/labstack/echo/cookbook/http2/server.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/vendor/github.com/labstack/echo/cookbook/http2/server.go b/vendor/github.com/labstack/echo/cookbook/http2/server.go
new file mode 100644
index 00000000..8db989c4
--- /dev/null
+++ b/vendor/github.com/labstack/echo/cookbook/http2/server.go
@@ -0,0 +1,42 @@
+package main
+
+import (
+ "fmt"
+ "net/http"
+ "time"
+
+ "github.com/labstack/echo"
+)
+
+func request(c echo.Context) error {
+ req := c.Request()
+ format := "<pre><strong>Request Information</strong>\n\n<code>Protocol: %s\nHost: %s\nRemote Address: %s\nMethod: %s\nPath: %s\n</code></pre>"
+ return c.HTML(http.StatusOK, fmt.Sprintf(format, req.Proto, req.Host, req.RemoteAddr, req.Method, req.URL.Path))
+}
+
+func stream(c echo.Context) error {
+ res := c.Response()
+ gone := res.CloseNotify()
+ res.Header().Set(echo.HeaderContentType, echo.MIMETextHTMLCharsetUTF8)
+ res.WriteHeader(http.StatusOK)
+ ticker := time.NewTicker(1 * time.Second)
+ defer ticker.Stop()
+
+ fmt.Fprint(res, "<pre><strong>Clock Stream</strong>\n\n<code>")
+ for {
+ fmt.Fprintf(res, "%v\n", time.Now())
+ res.Flush()
+ select {
+ case <-ticker.C:
+ case <-gone:
+ break
+ }
+ }
+}
+
+func main() {
+ e := echo.New()
+ e.GET("/request", request)
+ e.GET("/stream", stream)
+ e.Logger.Fatal(e.StartTLS(":1323", "cert.pem", "key.pem"))
+}