Questions tagged [rust-rocket]

A Rust web framework that uses unstable nightly features to provide a highly ergonomic and type-safe experience.

Rocket is a web framework for Rust that makes it simple to write fast web applications without sacrificing flexibility or type safety. All with minimal code.

Useful links

281 questions
2
votes
0 answers

React Axios POST fails when posting to Rocket.rs

I am trying to send a post request from my React application to my Rust Rocket API using Axios. The problem is that the the first request sent to the API get's blocked while every request after that goes through and even brings back response…
2
votes
0 answers

Rocket App hangs on linux while waiting for futex

I have a simple rocket 0.5.0-dev app main.rs #[macro_use] extern crate rocket; use rocket::http::{Status}; use rocket::State; use std::sync::{Mutex, Arc}; struct Event {} #[get("/health")] fn health() -> Result<&'static str, Status> { …
Yasammez
  • 1,383
  • 12
  • 15
2
votes
1 answer

Is there a clean way to serve React builds from a Rust Rocket backend

Normally React builds are just served as static files from a webserver like nginx but I want to serve the front end static files using Rust Rocket from a React build and I'm struggling to find a nice way of doing it, here are the routes I've set…
NiallJG
  • 1,881
  • 19
  • 22
2
votes
2 answers

Rust/rocket pass variable to endpoints

Not to my preference but I'm forced to write some Rust today so I'm trying to create a Rocket instance with only one endpoint but, on that endpoint I need to access a variable that is being created during main. The variable takes a long time to be…
Romeo Mihalcea
  • 9,714
  • 12
  • 50
  • 102
2
votes
1 answer

Multi-tenant web app with Rocket and Diesel

I have a multi-tenant web app that may need to support dozens of tenants (companies). I've been looking for a way to ensure that a tenant only has access to their own data (its important that there's no leaks) without having to pass around the…
Lee S.
  • 21
  • 2
2
votes
1 answer

Rust + Rocket: How I do read POST body from request as string?

I'm building a simple REST API using Rust and Rocket. One of the endpoints accepts a POST method request, and reads a large string from the request body. I can't figure out how to do this with Rocket. The documentation describes how to read a JSON…
simbro
  • 3,372
  • 7
  • 34
  • 46
2
votes
2 answers

Gives error 422 When I try to submit the form Rocket Rust

I'm trying to make a form to create posts(I'm not acessing db yet) in Rocket Rust. When I try to submit the form I get error 422. Error: POST /new_post application/x-www-form-urlencoded: => Matched: POST /new_post (new_post_form) => Error:…
2
votes
0 answers

How to forward data from a reqwest::blocking::Body in a Rocket responder?

I'm able to request a PNG file with reqwest which I can save to a file through copy(). I'd like to forward the image as a Rocket response. I don't know how to pass the response contents there. I tried to use Content(ContentType::PNG, response) but I…
simPod
  • 11,498
  • 17
  • 86
  • 139
2
votes
0 answers

Rust-rocket Match of request took very long (5 min)

I have a small rocket application which has some get Controller. One time a request took far too long and when I looked into the logs it was the time between getting the GET request and matching it with a controller: Hear are the log…
2
votes
1 answer

Trouble with POST declaration in Rust/Rocket

I am attempting to write a simple api with rocket to help myself learn rust but I have run into this error after I attempted declaring a POST route: error: malformed attribute --> src/main.rs:26:1 | 26 | #[post("/producers",…
ruffles
  • 23
  • 3
2
votes
1 answer

How can I respond to a POST request containing JSON data with Rocket?

I'm trying to create a backend using the Rocket crate: fn main() { rocket::ignite().mount("/", routes![helloPost]).launch(); } #[derive(Debug, PartialEq, Eq, RustcEncodable, FromForm)] struct User { id: i64, USR_Email: String, …
Mr. Developer
  • 3,295
  • 7
  • 43
  • 110
2
votes
1 answer

Using a custom Rocket Responder for an error in a RequestGuard

In a web server application using rocket.rs, I am using an Error type that implement Responder throughout my API. This error type ensures all errors are uniformly rendered (as RFC 7807 json). However, I can't find a way to use these Error responses…
Tomas
  • 5,067
  • 1
  • 35
  • 39
2
votes
2 answers

Rocket failing to compile

I am attempting to try out Rocket web framework with a very small example. However, Rocket (0.4.2) wont compile with the nightly rustc. (Using Ubuntu linux.) I am building using nightly rustc (2019-09-05). Just did a rustup to try the latest…
mcroxide
  • 51
  • 4
2
votes
1 answer

How to fix parsing errors in form POST request in Rocket?

I am making a very simple web app using the rust Rocket framework. I have a very simple HTML file that has a form, as follows:
Search Term:
Adrian Bernat
  • 65
  • 1
  • 9
2
votes
1 answer

How to convert Vec to JsonValue in Rust

I am querying my database and getting an Vec struct, using diesel library. #[derive(QueryableByName)] pub struct Bookable { #[sql_type = "BigInt"] pub id: i64, #[sql_type = "Text"] pub title: String } When I query the elements, I…
Alex
  • 715
  • 5
  • 14