1
0
mirror of https://github.com/actix/actix-website synced 2025-06-27 07:29:02 +02:00

migrate to docusaurus (v2) (#266)

Co-authored-by: ibraheemdev <ibrah1440@gmail.com>
This commit is contained in:
Santiago
2022-07-16 11:59:20 +02:00
committed by GitHub
parent a85b4ff5a3
commit 8393aea71a
85 changed files with 23020 additions and 4357 deletions

View File

@ -1,6 +1,7 @@
use actix_web::{web, App, HttpResponse, HttpServer, Responder};
use serde::{Deserialize, Serialize};
// <powerful-extractors>
#[derive(Deserialize, Serialize)]
struct Event {
id: Option<i32>,
@ -9,6 +10,12 @@ struct Event {
tags: Vec<String>,
}
async fn capture_event(evt: web::Json<Event>) -> impl Responder {
let new_event = store_in_db(evt.timestamp, &evt.kind, &evt.tags);
format!("got event {}", new_event.id.unwrap())
}
// </powerful-extractors>
fn store_in_db(timestamp: f64, kind: &str, tags: &[String]) -> Event {
// store item in db and get new_event
// use id to lookup item
@ -20,10 +27,6 @@ fn store_in_db(timestamp: f64, kind: &str, tags: &[String]) -> Event {
}
}
async fn capture_event(evt: web::Json<Event>) -> impl Responder {
let new_event = store_in_db(evt.timestamp, &evt.kind, &evt.tags);
format!("got event {}", new_event.id.unwrap())
}
async fn index() -> HttpResponse {
HttpResponse::Ok()