Questions tagged [rust-warp]

rust warp is a super-easy, composable, web server framework for warp speeds. The main concept in warp is the Filter.

warp is a super-easy, composable, web server framework for warp speeds. Thanks to its Filter system, warp provides these out of the box:

  • Path routing and parameter extraction
  • Header requirements and extraction
  • Query string deserialization
  • JSON and Form bodies
  • Static Files and Directories
  • Websockets
  • Access logging

The main concept in warp is the Filter, which allows composition to describe various endpoints in your web service. Besides this powerful trait, warp comes with several built in filters, which can be combined for your specific needs.

https://docs.rs/warp/

92 questions
1
vote
1 answer

disable http2 in seanmonstar/warp

I built a small web app using the crate warp. As it runs behind a reverse proxy, is it possible to build the warp crate without support for http2, so that compile time and binary size is reduced?
thejonny
  • 488
  • 2
  • 9
1
vote
1 answer

How to create a warp route based on the path suffix?

I need to create a route in warp for all URLs ending with an extension, regardless of the number of segments in the URL path, e.g. path.ext, some/path.ext and some/other/path.ext should be processed by the same route. The closer I could get to a…
Jon Mod
  • 11
  • 3
1
vote
1 answer

Root path example with warp?

This is the rust warp example for newbies to get started. It's supposed to be "super easy" but it currently makes me feel super stupid. use warp::Filter; #[tokio::main] async fn main() { // GET /hello/warp => 200 OK with body "Hello, warp!" …
LongHike
  • 4,016
  • 4
  • 37
  • 76
1
vote
1 answer

How to pass a std::sync::mpsc::Sender to a handler in warp?

In warp (rust), how can I pass a std::sync::mpsc::Sender to my business handlers? The following codes complains that std::sync::mpsc::Sender is not Sync. I understand that I possibly could wrap my_sender with something like…
Incömplete
  • 853
  • 8
  • 20
1
vote
1 answer

How to log request / response bodies in warp?

I am trying to log request / response bodies in warp. When using warp::log::custom, the Info struct doesn't contain any info about it. When trying to implement my own log wrapper, based on the implementation of warp::log, the Route struct is private…
Ltei
  • 425
  • 1
  • 6
  • 14
0
votes
0 answers

Create mock for warp::Part

I am trying to test my function definition like this: pub async fn validate( part: warp::Part, ) -> Result; To test it, I tried to create a Part object like this let part = Part { name: "".to_owned(), filename: None, …
amit
  • 177
  • 1
  • 13
0
votes
1 answer

Data stored in warp Session does not persist [SOLVED - but don't know why]

I am at the beginning of my Rust journey. Trying to set up a server backend as an exercise. I am stuck. Please help. I am trying to store some data in warp_sessions::MemoryStore but I cannot achieve it. I base on the…
Chris
  • 570
  • 2
  • 9
  • 19
0
votes
0 answers

How to resolve a Rust Reqwest Error: Invalid Certificate

Quick question, does reqwest allow self-signed certificates? I have created a tls enabled rust-warp webserver. And I have created a reqwest client to make requests to this server for testing purposes. The cert added to add_root_certificate is the…
0
votes
1 answer

How to connect SQL Server to Rust?

I'm new to Rust and have created REST API in Rust using Warp. I created a dummy grocery list API by following the tutorial from LogRocket Blog which uses local storage. Now, I want to add SQL Server to the code instead of local storage, but not sure…
0
votes
1 answer

Rust warp server issue when passing a handler with a generic

main.rs: use async_trait::async_trait; use tokio::runtime::Runtime; use warp::Filter; fn main() { //create http server let state = CState { inner: 2 }; Runtime::new().unwrap().block_on(async move { …
Brian Yeh
  • 3,119
  • 3
  • 26
  • 40
0
votes
1 answer

How can I post and save a photo using Rust Warp Multipart?

Rust warp multipart. How to post photo with warp and then save it as file? I've tried this code: pub async fn photos(form: warp::multipart::FormData) -> Result { let parts: Vec = form.try_collect().await.map_err(|e|…
AmALAks
  • 3
  • 2
0
votes
2 answers

Unclear expected type in Rust web server

I am trying to build a simple web server to upload and save images using rust. Here is my code: use std::convert::Infallible; use std::path::PathBuf; use warp::multipart::FormData; use warp::{http::StatusCode, Filter}; use…
tonyd629
  • 75
  • 7
0
votes
1 answer

Execute middleware before and after request in Rust warp

I would like to track in-flight connections in warp such that a metrics counter is incremented before the request is handled and decremented after it was processed. I attempted to solve this by using a "no-op" filter in the start of the chain and a…
sunside
  • 8,069
  • 9
  • 51
  • 74
0
votes
0 answers

In Rust using warp, how do I build filters by configuration?

Starting with a root path: let root = warp::path::end() .map(|| "Hello World, at root!"); I would like to construct .or() Filters by configuration: for path in web_server_config.paths { root.or(warp::path(path).map(|| "OK")); // or any…
johnDisplayClass
  • 269
  • 3
  • 11
0
votes
0 answers

How to pass HashMap parameters to a function in Warp Rust

I'm fairly new to rust programming, and I'm following the rust book. However, I recently started to make some exercises by myself to "deepen" my understanding. I came into an issue with Warp, particularly post requests. Basically, what I am trying…
Dave S.
  • 88
  • 8