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
0
votes
0 answers

Rust warp redirect removing some headers

I'm trying to redirect requests to some URL. My server is using rust with warp. The library https://docs.rs/warp-reverse-proxy/latest/warp_reverse_proxy/ seems to do exactly what I need, but when it redirects with all the headers the server…
Ainestal
  • 1
  • 2
0
votes
0 answers

Warp/Hyper shared datastructure

Suppose you have a web server that receives requests via an async closure, like in hyper or warp. You want requests to modify a shared datastructure—e.g. a running count of all requests so far, or a list of the first byte of each request. How do you…
Test
  • 962
  • 9
  • 26
0
votes
0 answers

Passing generic enums in Warp query

I have an enum that is serde serializable in Rust.The enum has generics involved. Is there a way to get warp to accept this enum as a part of a warp query. enum A { a(T), } such that we can have , let route = warp::get() …
roku675
  • 59
  • 1
  • 5
0
votes
0 answers

How to parse paramemters in URL as a HashMap?

I have a client A and I am going to write a Proxy B to proxy some HTTPS/HTTP requests from A to C. B is just a proxy I don't care about what the parameters are. The parameters have be stored in the URL(not body),…
YNX
  • 511
  • 6
  • 17
0
votes
1 answer

How can I conditionally disable api routes in warp?

I am new to Rust and Warp and I am trying to make routes available conditionally. For example, I have a route /leaves, and based upon the flag I need to process this request or send an error response. let enable_api = true // some config part let…
salman01z
  • 101
0
votes
1 answer

Show anchor/fragment in Rust Iron framework?

I'm building a tool around an oauth implicit flow, which means that I eventually need to pull the access token from some URL in a request. I'm trying to build with Iron (I've also looked at Warp), but it looks like anchor tags are stripped in the…
hjfitz
  • 399
  • 4
  • 15
0
votes
1 answer

Why can't I use a multi-line builder pattern

I have started looking into Rust (and Warp) just a few days ago. I can't get into my head the following: Given the following endpoints let hi = warp::path("hi"); let bye = warp::path("bye"); let howdy = warp::path("howdy"); Why is the…
JAnton
  • 1,095
  • 8
  • 16
0
votes
0 answers

Why Rust Return Type Infer Diffent With IDE?

use futures_util::{FutureExt, StreamExt}; use warp::{Filter, filters::BoxedFilter, Reply}; // websocket echo pub fn websocket_filter() -> BoxedFilter<(impl Reply, )> { return warp::path!("echo") .and(warp::ws()) .map(|ws:…
AidonCason
  • 63
  • 5
0
votes
1 answer

Into for String

I'm trying to give a String to the warp::server().run() function as the listening address. But I do not know how to impl Into for String. Code use warp::Filter; #[tokio::main] async fn main() { // GET /hello/warp => 200 OK with body…
ashwin vinod
  • 156
  • 1
  • 1
  • 13
0
votes
0 answers

How to log failures to deserialize

I have made a rust webserver using Warp. When I send a request to the webserver, it cannot deserialize the given body. I know exactly why this error happens, and am not asking about how to fix the deserializatin error. The issue that I have is that…
kingledion
  • 2,263
  • 3
  • 25
  • 39
0
votes
1 answer

When is it appropriate to implement Send + Sync for static dispatch

I find myself playing around with warp. I would like to pass a database Trait to a warp::Filter using static dispatch, such that the concrete database may vary. I read that Send + Sync are unsafe to implement, but I don't fully understand when it is…
kruserr
  • 463
  • 4
  • 8
0
votes
1 answer

Rust: Tokio + Warp run in background

Rust newbie here since I recently started working on it. I'm trying get a rest api working and the following code works completely fine for me. MyRest.rs pub struct RestBro; impl RestBro { pub async fn run_bro() { let routes_post =…
M. Ather Khan
  • 305
  • 1
  • 2
  • 9
0
votes
1 answer

How can I check the error kind from Warp's try_bind_with_graceful_shutdown?

How can I check if the error from try_bind_with_graceful_shutdown is std::io::ErrorKind::AddrInUse?
Lightstorm
  • 379
  • 4
  • 5
0
votes
0 answers

Multiple types of Ok() in a Rust warp handler gives error

I'm pretty new to Rust and I don't appear to understand why This code example is a web handler using an external database with warp: use super::data; use std::convert::Infallible; pub async fn get_product(id: u32, repo: data::Repository) ->…
kingledion
  • 2,263
  • 3
  • 25
  • 39
0
votes
0 answers

How to setup an async Database connection on the Context in Juniper Warp

I am setting up a Juniper GraphQL server with Warp and I need to initialise a mongodb Database connection on the Context. I am very new to Rust so not sure the right way to do this. I am currently attempting to await the setup of the context and…
Dave Taylor
  • 1,931
  • 2
  • 17
  • 30