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
2 answers

Handlebars helpers within Rocket

I am trying to register a helper for handlebars the ultimate goal is to be able to have a helper that calculates/prints the length of a Vec. But I already fail to get the samples from the documentation into my program. I managed to do a 'minimal'…
enaut
  • 431
  • 4
  • 15
0
votes
1 answer

How can I define an optional subpath with Rocket?

I am trying to package a Vue app under a Rocket served path (under /admin). I have written the following matchers: #[get("/admin/")] fn admin_panel(_admin: AdminUser, path: Option) -> Option { match path { …
Daniel Gray
  • 1,697
  • 1
  • 21
  • 41
0
votes
1 answer

I get a "no 'Json' in root" error when building a rust rocket api

So I was trying to follow the example from https://medium.com/sean3z/building-a-restful-crud-api-with-rust-1867308352d8 to build a simple REST API. Half way through, the rust compiler gives me the the following error: unresolved imports…
MWhatsUp
  • 41
  • 6
0
votes
1 answer

Correct way of sending image via AJAX in JSON to Rocket server

I am trying to build a Rust Web App using Rocket that uploads images from the client. My problem is that I don't know how to encode the data of an uploaded image (the pixels) into a JSON on the client side. This data would be later send via…
carrasco
  • 176
  • 11
0
votes
1 answer

Rust: how to convert SocketAddr to IpNetwork?

Using Diesel and Rocket I want to be able to log IPs that requests are coming from. Here is the similar discussion, but without conclusion. Diesel maps Postgres inet type to IpNetwork, but Rocket returns SocketAddr from the request data. How to…
SS_Rebelious
  • 1,274
  • 2
  • 19
  • 35
0
votes
1 answer

Return single record created in PostgreSQL using Rocket and Diesel (Rust)

I'm trying to build a simple web app based on tutorials: one, two and three. All of them uses slightly different approaches and were written for older versions of the used libraries, so current Diesel and Rocket API slightly differs. I want in…
SS_Rebelious
  • 1,274
  • 2
  • 19
  • 35
0
votes
1 answer

Request to rust rocket server getting error connection refused from JavaScript app

I have a rust server running in my machine at localhost, port:4200. I am trying to make requests to this server using a JavaScript client that uses axios library. The code when run gives the following error: Error: connect ECONNREFUSED…
Sanjay S B
  • 259
  • 2
  • 15
0
votes
1 answer

How to create Response from String?(Rust-Rocket)

I tried to implement the Responder trait for "MyConfig" struct. But I don't know how to create Response (including the body whose type is String) which can be return from function. I tried this code. #[derive(Debug)] struct MyConfig { body:…
lenna_kun
  • 43
  • 5
0
votes
0 answers

How to Serialize context for Template::render

I'm trying to use Handlebars with Rocket and Diesel. Unfortunately I didn't get this combination to work. First I build a simple rest-API using this tutorial. Then I tried to test a handlebars-template without using the database-connection. This…
Red-Ex
  • 1
  • 1
0
votes
1 answer

The specified procedure could not be found. (os error 127) - #![plugin(rocket_codegen)]

I am a newbie with Rust programming and I am building Rust + Diesel + Rocket framework. When I run the command cargo check or cargo run, the following error occurs: The specified procedure could not be found. (os error 127) --> src\main.rs:2:11 | 2…
CdVr
  • 323
  • 3
  • 15
0
votes
1 answer

An opened image as a global variable?

I'd like to write a server that resizes a huge image. Since loading it on every request would take a lot of time, I decided to pre-load it. Unfortunately I got the following error: Compiling hello_world v0.0.0 (/tmp/Rocket/examples/hello_world) …
d33tah
  • 10,999
  • 13
  • 68
  • 158
0
votes
1 answer

What could cause a Docker image with a Rocket application to use very different memory when running on different Docker hosts?

I have a Rocket web application packed into a Docker image. The application uses 4 or 5 times of more memory on start when deployed and running inside our Kubernetes environment (some Linux Docker host), than the memory usage of it running as a…
Fuyang Liu
  • 1,496
  • 13
  • 26
0
votes
1 answer

Rocket Framework sample does not compile

I tried to install Rust nightly and compile Rocket's hello_world sample project. I got this error: error[E0599]: no associated item named `Lifetime` error[E0599]: no associated item named `Lifetime` found for type `syntax::ast::GenericParam` in the…
azwar_akbar
  • 1,451
  • 18
  • 27
0
votes
1 answer

Can't return String from Rocket route

I'm trying to create a Rocket route that returns a string to the client, but I can't get it to work. So far, this is what I have: #![feature(plugin)] #![plugin(rocket_codegen)] #[macro_use] extern crate serde_derive; extern crate toml; extern crate…
chenshuiluke
  • 319
  • 1
  • 16
0
votes
1 answer

How to display the value retrieved using Diesel in HTML using a Tera template in Rocket?

I want to display a value retrieved from the database with Diesel and serve it as HTML using a Tera template with Rocket: #[get("/")] fn index(db: DB) -> Template { use mlib::schema::users::dsl::*; let query =…
lion
  • 25
  • 5
1 2 3
18
19