Axum is a domain specific concurrent programming language, based on the Actor model, being developed by Microsoft.
Questions tagged [axum]
31 questions
0
votes
0 answers
Getting column data using SQLx with Rust
I am using Axum and sqlx to build an api endpoint that takes a table name and returns all the data in the table in the form of json. The number of columns and their types are not known beforehand. What would be the best way to go about this.
I did…

ExcalPrime0
- 1
- 1
0
votes
1 answer
Best way to create a session cookie if it's not present and persist to a database using axum and tower_cookies?
I'm relatively new to axum and I'm trying to use it as the webserver for a service I'm creating.
I have some state which contains a database I would like to write session / session metadata to.
I want all users which access any route to set a…

druckermanly
- 2,694
- 15
- 27
0
votes
0 answers
Problem with fields when working with sqlx in rust
I am working on a REST API written in Rust using axum, sqlx and PostgreSQL.
There are the following two models:
#[derive(FromRow, Serialize)]
pub struct Brand {
id: i32,
title: String,
#[sqlx(flatten)]
product:…
0
votes
1 answer
Implemented a Controller merging routing and handling; Getting 404 -- suspect a Rust tenant violation
I am working with Rust and Axum on a simple REST API project. What I am trying to accomplish is to merge a route, http verb, and handler together to mimic what controllers in other languages/frameworks do. Everything is looking really good except…

A Bit of Help
- 1,368
- 19
- 36
0
votes
0 answers
Parse bytes in URL queries in Rust Axum
In order to learn Rust, I plan to develop a bittorrent tracker.
But I ran into a problem:
async fn announce(
RawQuery(rawquery): RawQuery,
Query(query_map): Query>,
) -> impl IntoResponse {
let rawquery =…

3moredays
- 25
- 3
0
votes
0 answers
Questio on trait bounds in Axum::routing::get
For training purposes I am trying to implement a google Oauth solution in axum, but I have run into a problem that I am having a hard time wrapping my head around.
For context i have a simple server setup as follows:
use axum::{
routing::{get},
…

Alex S
- 231
- 1
- 10
0
votes
0 answers
Why is this Axum handler throwing error if I inlline this sleep function's arguments?
I was facing this strange issue where I have this axum handler
async fn login(...) -> Result {
if let Some(user) = get_user(...) {
...
}
tokio::time::sleep(
…

Cyan Froste
- 83
- 5
0
votes
0 answers
Ownership and creating an AppState for an Axum server using the `whisper_rs` crate
I'm trying to create a whisper-rs server using Axum. In this server I'd like to only have to create the whisper state once at server startup. Hence, I created an AppState struct that could then be passed around using an…

wdoppenberg
- 66
- 3
0
votes
0 answers
Why do some on my API routes return 404 errors (sometimes) in Axum?
I am using Axum to serve a React frontend which makes api calls to the same Axum server for it's backend. However, sometimes the server returns 404 errors for only some of my API routes. When I load the frontend, some of the routes say "404" in my…

cantfetzthis
- 43
- 4
0
votes
1 answer
for axum, how to set a header for a handler
I can't seem to find how to set a header for the response.
I have looked for how to do this but haven't found a straightforward way to do this.
With specific emphasis on the content-type header, How to set both a standard & custom headers from a…

Thermatix
- 2,757
- 21
- 51
0
votes
1 answer
Handling dependency-injection and errors in Rust, using Axum
I'm trying to wrap my head around how to handle this particular issue in Rust. I've programmed in Rust for a while, but I'm primarily a C# developer, and some of my knowledge in that language might be confusing me with this problem.
I have a web…

Christian Schmid
- 11
- 3
0
votes
0 answers
How can I return a result in axum?
I've been writing a simple crud app in Axum and Sea-orm, but I keep getting when trying to handle a Database Error.
Here's the create user function:
async fn create_user(Json(user_input): Json) -> Result, Json> {
let…

Xetify
- 41
- 1
- 4
0
votes
1 answer
Unexplained trait bound no longer satisfied when modifying Axum handler body
Recently, I've started to learn Rust to build some simple web apps with Axum. However, I ended having an unexplained error while building the app, and I could not find the reason of it.
The failing to be built application code is the following:
use…

Patrick
- 2,587
- 16
- 21
0
votes
2 answers
Send a DynamicImage as a response with axum
I tried to send a PNG as GET-response to a client with axum. For this I load an image into a DynamicImage from the image crate. When I send a request from my browser, no image is shown. In firefox I get the message:
The image…

Pangaeanain
- 37
- 1
- 6
0
votes
0 answers
Rust Async Graphql Json InputObject Type
I'm trying to use Async Graphql, I want to use sqlx json type in model. In normal api operations the code is running. But when I want to use the async graphql InputObject macro, I get an error. The codes I used are as follows, I couldn't find a…

Saadettin Yasir AKEL
- 71
- 1
- 8