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

How to serialize trait object with rocket::serde?

I've got the following code: use std::fmt::Debug; use rocket::serde::{Serialize}; #[serde(crate = "rocket::serde")] pub trait ComponentDto: Debug + Send + Sync + Serialize {} use rocket::serde::{Deserialize,…
WoFVi
  • 21
  • 1
0
votes
1 answer

thread 'main' panicked at 'assertion failed: self.remaining() >= dst.len()' when trying to connect database MYSQL

So when i try to connect mysql database main tread panics it was working fine with sqlite but when i try to use it with mysql it's not working. cargo check is also working fine. The error is located at line 20 where i created a database…
0
votes
1 answer

Rust Rocket - Having trouble importing modules

I am working on a Rust project with Rocket. I am unable to get some modules imported properly into my code. For example, I am trying to import "rocket::form". Here is my cargo.toml file, and my main.rs file: cargo.toml [package] name = "..." version…
user545642
  • 91
  • 1
  • 14
0
votes
1 answer

Confirguring Rocket 0.5 TLS with NO-IP trrustcor certification

I've been using Rust-lang Rocket v0.5-rc for the past couple of weeks in order to create my web application. In order to get my SSL certificate and a domain name, I've been using NO-IP free services. I generated a 2048 bit RSA key with OpenSSL,…
0
votes
1 answer

DeserializationError - failed to fill whole buffer

I'm writing a simple rust app using the Rocket web framework, Postgres database, and Diesel to manage database migrations. The code compiles OK, and other parts of the application run properly, but for some reason, my Expense endpoints don't seem to…
grizzthedj
  • 7,131
  • 16
  • 42
  • 62
0
votes
1 answer

How to find().lean() in Rust mongodb?

I am trying to make mongodb Document plain in order to apply okapi's open api which does not allow ObjectId in struct. But I found neither building a find option like FindOptions::builder().lean().build(); nor colleciton.find(None,…
HumbleCoder
  • 576
  • 1
  • 5
  • 19
0
votes
0 answers

How to implement a `rocket::request::FromRequest` to a tuple struct?

TLDR; Is it possible to implement rocket::request::FromRequest in a tuple struct? (Or is it called newtype idiom?) #[cfg(target_os = "windows")] pub struct IpAddWrapper(std::net::SocketAddr); #[cfg(any(not(target_os = "windows"), feature =…
MikeTheSapien
  • 161
  • 3
  • 8
0
votes
1 answer

Rocket cannot parse JSON

I'm having an error when trying to parse JSON with rocket. This is my code: extern crate serde; use rocket::serde::{json::Json, Deserialize}; use serde::Serialize; #[macro_use] extern crate rocket; mod eth; mod rocket_test; #[launch] fn rocket() ->…
Gabriel Machado
  • 401
  • 3
  • 14
0
votes
1 answer

is it possible to use enum to parse the request in rust rocket

I want to do a condition query in rust diesel(diesel = { version = "1.4.7", features = ["postgres","64-column-tables","chrono"] }). read the docs from here and write the fuction like this: fn find_channel(request: &ChannelRequest) -> Box
Dolphin
  • 29,069
  • 61
  • 260
  • 539
0
votes
1 answer

Why does route not compile when returning non-Responder error in Rocket?

The Rocket documentation says this: If the error type E does not implement Responder, then the error is simply logged to the console, using its Debug implementation, and a 500 error is returned to the client. I have a route with this signature,…
Alper
  • 3,424
  • 4
  • 39
  • 45
0
votes
0 answers

Juniper rust: sharing request data with the resolvers with the FromRequest trait

can anyone help get my head around the FromRequest trait. As I understand, we can use it to share data with the resolvers. I'm trying to inject the http headers so I can authenticate users before some actions in the resolvers. See my code…
user1445685
  • 793
  • 1
  • 11
  • 25
0
votes
1 answer

CORS Fairing in Rocket Causing Lifetime Errors

I'm trying to add a CORS policy to my rocket API. I've tried a couple ways but the closest (I think) and most straightforward way so far has been to add a custom Fairing that sets the CORS headers in the on_response hook. I've been using the…
BWStearns
  • 2,567
  • 2
  • 19
  • 33
0
votes
1 answer

How to use shared variables Rust's Rocket web framework?

I'm trying to use shared resources in the routing functions, like accessing the variable "shared_resource" in my hello() function #[launch] fn rocket() -> _ { let shared_resource = SharedResource::new() rocket::build().mount("/",…
hwa
  • 1
  • 1
0
votes
1 answer

get title from Zotero item

Still very new to Rust, trying to understand how to extract the title of a JournalArticle using the Zotero crate. I've got this, and can confirm the item is retrieved successfully: let zc = ZoteroCredentials::new(); let z =…
ghukill
  • 1,136
  • 17
  • 42
0
votes
0 answers

Can I end a path on a dynamic segment with a file extension

Using rocket v0.5-rc I want to return HTML when /leaderboard/2021 is requested, but JSON when /leaderboard/2021.json is requested. The year here should be dynamic. I wrote the following two functions: #[get("/leaderboard/")] fn…
Netråm
  • 453
  • 6
  • 12