From bbd30b6e2808730391713194cbcda871c64c06e3 Mon Sep 17 00:00:00 2001 From: andrewlalis Date: Thu, 9 Jan 2025 21:58:32 -0500 Subject: [PATCH] Added some content to the readme. --- README.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a6e06ad..37540cd 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,26 @@ # http-transport -Implementations of HTTP transport protocols, compatible with other Handy-Http components. \ No newline at end of file +Implementations of HTTP transport protocols, compatible with other Handy-Http components. + +## HTTP/1.1 + +Use the `Http1Transport` implementation of `HttpTransport` to serve content +using the HTTP/1.1 protocol. See the example below: + +```d +import handy_http_primitives; +import handy_http_transport; + +class MyHandler : HttpRequestHandler { + void handle(ref ServerHttpRequest req, ref Server HttpResponse resp) { + response.status = HttpStatus.OK; + response.headers.add("Content-Type", "text/plain"); + response.outputStream.writeToStream(cast(ubyte[]) "Hello world!"); + } +} + +void main() { + HttpTransport tp = new Http1Transport(new MyHandler(), 8080); + tp.start(); +} +``` \ No newline at end of file