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:
@ -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()
|
||||
|
Reference in New Issue
Block a user