1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! EdgeDB WebAssembly SDK
//!
//! # Example
//!
//! The primary use of this SDK is to create a web handler, and to make some
//! database queries inside that handler. Somewhat minimal example:
//!
//! ```rust,no_run
//! use edgedb_sdk::web;
//! use edgedb_sdk::client::{Client, create_client};
//! use once_cell::sync::Lazy;
//!
//! static CLIENT: Lazy<Client> = Lazy::new(|| create_client());
//!
//! #[web::handler]
//! fn handler(_req: web::Request) -> web::Response {
//! let query_result = CLIENT.query_required_single::<i64, _>(
//! "SELECT 7*8",
//! &(),
//! );
//! match query_result {
//! Ok(value) => {
//! web::response()
//! .status(web::StatusCode::OK)
//! .header("Content-Type", "text/html")
//! .body(format!("7 times 8 is {value}").into())
//! .expect("response is built")
//! }
//! Err(e) => {
//! log::error!("Error handling request: {:#}", e);
//! web::response()
//! .status(web::StatusCode::INTERNAL_SERVER_ERROR)
//! .header("Content-Type", "text/plain")
//! .body(format!("Internal Server Error").into())
//! .expect("response is built")
//! }
//! }
//! }
//! ```
pub use init_hook;
extern "C"