turns out Bytes implements FromRequest
This commit is contained in:
parent
a3dab56ddb
commit
8329c75ccf
2 changed files with 4 additions and 5 deletions
|
@ -28,7 +28,7 @@
|
||||||
path = ./.;
|
path = ./.;
|
||||||
};
|
};
|
||||||
|
|
||||||
cargoSha256 = "sha256-6aA95Zm1FGp8xiv55QSBZFfmBXWz5pygc/8uQHvy3tM=";
|
cargoSha256 = "sha256-YZHQCFojC8Ch9jcyxXLKEVsMNtI4ufzbCPUPLbUkMCI=";
|
||||||
};
|
};
|
||||||
in rec {
|
in rec {
|
||||||
packages = forAllSystems (s: let
|
packages = forAllSystems (s: let
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::fmt::Debug;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use axum::{
|
use axum::{
|
||||||
async_trait,
|
async_trait,
|
||||||
extract::{FromRef, FromRequestParts, Query, RawBody, State},
|
extract::{FromRef, FromRequestParts, Query, State},
|
||||||
http::{header::AUTHORIZATION, request::Parts, HeaderValue, StatusCode},
|
http::{header::AUTHORIZATION, request::Parts, HeaderValue, StatusCode},
|
||||||
response::{IntoResponse, Response},
|
response::{IntoResponse, Response},
|
||||||
routing::{delete, get, post},
|
routing::{delete, get, post},
|
||||||
|
@ -14,7 +14,7 @@ use bb8::Pool;
|
||||||
use bb8_redis::RedisConnectionManager;
|
use bb8_redis::RedisConnectionManager;
|
||||||
use hex::FromHex;
|
use hex::FromHex;
|
||||||
use hyper::{
|
use hyper::{
|
||||||
body::to_bytes,
|
body::Bytes,
|
||||||
header::{CONTENT_TYPE, ETAG, IF_NONE_MATCH},
|
header::{CONTENT_TYPE, ETAG, IF_NONE_MATCH},
|
||||||
Method,
|
Method,
|
||||||
};
|
};
|
||||||
|
@ -358,10 +358,9 @@ async fn delete_data(
|
||||||
async fn set_data(
|
async fn set_data(
|
||||||
AuthenticatedUser(id): AuthenticatedUser,
|
AuthenticatedUser(id): AuthenticatedUser,
|
||||||
RedisConnection(mut conn): RedisConnection,
|
RedisConnection(mut conn): RedisConnection,
|
||||||
RawBody(body): RawBody,
|
body: Bytes,
|
||||||
) -> Result<Json<serde_json::Value>, WrappedError> {
|
) -> Result<Json<serde_json::Value>, WrappedError> {
|
||||||
let now = (OffsetDateTime::now_utc().unix_timestamp_nanos() / 1000) as u64;
|
let now = (OffsetDateTime::now_utc().unix_timestamp_nanos() / 1000) as u64;
|
||||||
let body = to_bytes(body).await?;
|
|
||||||
redis::cmd("HSET")
|
redis::cmd("HSET")
|
||||||
.arg(id)
|
.arg(id)
|
||||||
.arg("last_modified")
|
.arg("last_modified")
|
||||||
|
|
Loading…
Reference in a new issue