summaryrefslogtreecommitdiffstats
path: root/third_party/rust/warp/examples/README.md
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /third_party/rust/warp/examples/README.md
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/warp/examples/README.md')
-rw-r--r--third_party/rust/warp/examples/README.md68
1 files changed, 68 insertions, 0 deletions
diff --git a/third_party/rust/warp/examples/README.md b/third_party/rust/warp/examples/README.md
new file mode 100644
index 0000000000..1b3bb8a2ae
--- /dev/null
+++ b/third_party/rust/warp/examples/README.md
@@ -0,0 +1,68 @@
+# Examples
+
+Welcome to the examples! These show off `warp`'s functionality and explain how to use it.
+
+## Getting Started
+
+To get started, run `examples/hello.rs` with:
+
+```bash
+> cargo run --example hello
+```
+
+This will start a simple "hello world" service running on your localhost port 3030.
+
+Open another terminal and run:
+
+```bash
+> curl http://localhost:3030/hi
+Hello, World!%
+```
+
+Congratulations, you have just run your first warp service!
+
+You can run other examples with `cargo run --example [example name]`:
+
+- [`hello.rs`](./hello.rs) - Just a basic "Hello World" API
+- [`routing.rs`](./routing.rs) - Builds up a more complex set of routes and shows how to combine filters
+- [`body.rs`](./body.rs) - What's a good API without parsing data from the request body?
+- [`headers.rs`](./headers.rs) - Parsing data from the request headers
+- [`rejections.rs`](./rejections.rs) - Your APIs are obviously perfect, but for silly others who call them incorrectly you'll want to define errors for them
+- [`futures.rs`](./futures.rs) - Wait, wait! ... Or how to integrate futures into filters
+- [`todos.rs`](./todos.rs) - Putting this all together with a proper app
+
+## Further Use Cases
+
+### Serving HTML and Other Files
+
+- [`file.rs`](./file.rs) - Serving static files
+- [`dir.rs`](./dir.rs) - Or a whole directory of files
+- [`handlebars_template.rs`](./handlebars_template.rs) - Using Handlebars to fill in an HTML template
+
+### Websockets
+
+Hooray! `warp` also includes built-in support for WebSockets
+
+- [`websockets.rs`](./websockets.rs) - Basic handling of a WebSocket upgrade
+- [`websockets_chat.rs`](./websockets_chat.rs) - Full WebSocket app
+
+### Server-Side Events
+
+- [`sse.rs`](./sse.rs) - Basic Server-Side Event
+- [`sse_chat.rs`](./sse_chat.rs) - Full SSE app
+
+### TLS
+
+- [`tls.rs`](./tls.rs) - can i haz security?
+
+### Autoreloading
+
+- [`autoreload.rs`](./autoreload.rs) - Change some code and watch the server reload automatically!
+
+### Debugging
+
+- [`tracing.rs`](./tracing.rs) - Warp has built-in support for rich diagnostics with [`tracing`](https://docs.rs/tracing)!
+
+## Custom HTTP Methods
+
+- [`custom_methods.rs`](./custom_methods.rs) - It is also possible to use Warp with custom HTTP methods.