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
-1
votes
1 answer

Serialize HashSet of enum variants as a regular HashMap using rocket serde

#[derive(Deserialize, Serialize)] enum En { A(i32), B(String) } #[derive(Deserialize, Serialize)] struct Data { data: Mutex> } When using this structure, serializing the struct outputs something like {"data": [{"A": 0},…
Ontley
  • 1
  • 5
-1
votes
1 answer

How can I fix my error 'thread 'rocket-worker-thread' panicked at 'called `Option::unwrap()` on a `None` value', src\main.rs:25:44'?

I'm coding a basic video streaming website, and am having trouble parsing json into rust. When I attempt to access the page 'http://127.0.0.1:8000/genres' I get a 500 response and in the console it says GET /genres text/html: >> Matched:…
prorex
  • 3
  • 2
-1
votes
1 answer

Rust rocket can't find the ignite function

I try to use the rocket::ignite() function like here. If I implement it in my code: fn main() { rocket::ignite() .mount("/", routes![stream_controller::index]) .mount("/events", routes![stream_controller::events]) …
Jan
  • 93
  • 9
-1
votes
1 answer

modify hello world in rocket rust to print variable string with the text

i want my hello world to display hello, {} but everything i do not working and i have absolutely no idea how to solve the errors i get here is my code: #[macro_use] extern crate rocket; use std::fmt::format; #[get("/")] fn index() -> &str { …
curlynux
  • 1
  • 3
-1
votes
1 answer

How to add X-Total-Count to header response in Rocket Rust REST API?

I create a REST API with Rust and Rocket that works with swagger. Now I'm trying to consumes this API with React react-admin to be precise. Everything works OK until I need to call a list where the famous X-Total-Count problem appears, and I am not…
goja288
  • 13
  • 3
-1
votes
1 answer

Rust: Thread panics when run inside an iframe but not in a regular browser tab

I'm playing around with building an app on Zendesk using Rust. Below is a server-side rust function that gets called in a route pub fn oktaredirectprocessor(mut cookies: Cookies, code: String, state: String) -> bool { let cookie_state_string =…
nalin
  • 3
  • 5
-1
votes
1 answer

Function with a generic parameter type

I am using the Rocket web framework and I need to create a function with a generic parameter type parameter: use rocket_contrib::json::{Json, JsonValue}; fn bluid_succes_response(data: T) -> JsonValue { json!(data) } This is the error I…
-1
votes
1 answer

Rocket cannot find a route if I use a FromRequest param on a GET

I cannot use a param that implements FromRequest with a method #get. It works perfectly with a #post In the code below, the /keyserver/key (GET) works as long as I don't use the header param. Otherwise, I get a : GET /keyserver/key text/html: =>…
the duck
  • 375
  • 3
  • 13
-1
votes
1 answer

Diesel fetch single parent and many children - Rocket

I've been able to get all parents along with all children Anyone has an idea how to get a single parent with all children? pub struct CityAndNeighbourhoods(CustomerCity, Vec>); pub fn…
moh_abk
  • 2,064
  • 7
  • 36
  • 65
-3
votes
1 answer

can not load style sheet

I am using rocket to make a web server that serves markdown as html. It was going OK until I tried to use css. It loads, but my CSS settings were not working. When I opened up the Inspector, It gave this error: can not load style sheet my rust…
moth
  • 7
  • 1
  • 3
-5
votes
1 answer

How change port using rocket (rust)?

How can i change the port running rocket? The default port is 8000 but it's already busy in my laptop, i wish to change. My Cargo.toml : [package] name = "hello_world" version = "0.1.0" edition = "2021" # See more keys and their definitions at…
1 2 3
18
19