MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / handler_get

Function handler_get

examples/proxy_cloudflare_worker_example/src/route.rs:30–61  ·  view source on GitHub ↗
(
    State(state): State<CFEnv>,
)

Source from the content-addressed store, hash-verified

28}
29
30async fn handler_get(
31 State(state): State<CFEnv>,
32) -> Result<impl IntoResponse, (StatusCode, String)> {
33 let env = state.env.clone();
34 let db = crate::orm::init_db(env).await.map_err(|err| {
35 console_log!("Failed to connect to database: {:?}", err);
36 (
37 StatusCode::INTERNAL_SERVER_ERROR,
38 "Failed to connect to database".to_string(),
39 )
40 })?;
41
42 let ret = crate::entity::Entity::find()
43 .all(&db)
44 .await
45 .map_err(|err| {
46 console_log!("Failed to query database: {:?}", err);
47 (
48 StatusCode::INTERNAL_SERVER_ERROR,
49 "Failed to query database".to_string(),
50 )
51 })?;
52 let ret = serde_json::to_string(&ret).map_err(|err| {
53 console_error!("Failed to serialize response: {:?}", err);
54 (
55 StatusCode::INTERNAL_SERVER_ERROR,
56 "Failed to serialize response".to_string(),
57 )
58 })?;
59
60 Ok(ret.into_response())
61}
62
63async fn handler_generate(
64 State(state): State<CFEnv>,

Callers

nothing calls this directly

Calls 2

init_dbFunction · 0.85
allMethod · 0.45

Tested by

no test coverage detected