trisquel-icecat/icecat/third_party/rust/warp/examples
2025-10-06 02:35:48 -06:00
..
dir icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
tls icecat: add release 140.3.1-1gnu1 2025-10-06 02:35:48 -06:00
autoreload.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
body.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
compression.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
custom_methods.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
dir.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
dyn_reply.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
file.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
futures.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
handlebars_template.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
headers.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
hello.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
multipart.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
query_string.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
README.md icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
rejections.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
returning.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
routing.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
sse.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
sse_chat.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
stream.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
tls.rs icecat: add release 140.3.1-1gnu1 2025-10-06 02:35:48 -06:00
todos.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
tracing.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
unix_socket.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
websockets.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
websockets_chat.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00
wrapping.rs icecat: initial release for Trisquel 12.0, Ecne 2025-07-17 09:32:21 -06:00

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:

> cargo run --example hello

This will start a simple "hello world" service running on your localhost port 3030.

Open another terminal and run:

> 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 - Just a basic "Hello World" API
  • routing.rs - Builds up a more complex set of routes and shows how to combine filters
  • body.rs - What's a good API without parsing data from the request body?
  • headers.rs - Parsing data from the request headers
  • 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 - Wait, wait! ... Or how to integrate futures into filters
  • todos.rs - Putting this all together with a proper app

Further Use Cases

Serving HTML and Other Files

Websockets

Hooray! warp also includes built-in support for WebSockets

Server-Side Events

TLS

  • tls.rs - can i haz security?

Autoreloading

  • autoreload.rs - Change some code and watch the server reload automatically!

Debugging

Custom HTTP Methods