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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#![deny(missing_docs)]
pub mod outbound_http;
pub use spin_macro::*;
pub mod http {
use anyhow::Result;
pub type Request = http::Request<Option<bytes::Bytes>>;
pub type Response = http::Response<Option<bytes::Bytes>>;
pub use crate::outbound_http::send_request as send;
pub fn not_found() -> Result<Response> {
Ok(http::Response::builder()
.status(404)
.body(Some("Not Found".into()))?)
}
pub fn internal_server_error() -> Result<Response> {
Ok(http::Response::builder()
.status(500)
.body(Some("Internal Server Error".into()))?)
}
}
#[allow(missing_docs)]
pub mod redis {
wit_bindgen_rust::import!("../../wit/ephemeral/outbound-redis.wit");
pub use outbound_redis::*;
}
pub mod pg;
pub mod mysql;
#[allow(missing_docs)]
pub mod config {
wit_bindgen_rust::import!("../../wit/ephemeral/spin-config.wit");
pub use spin_config::{get_config as get, Error};
impl ::std::fmt::Display for Error {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
match self {
Error::Provider(provider_err) => write!(f, "provider error: {}", provider_err),
Error::InvalidKey(invalid_key) => write!(f, "invalid key: {}", invalid_key),
Error::InvalidSchema(invalid_schema) => {
write!(f, "invalid schema: {}", invalid_schema)
}
Error::Other(other) => write!(f, "other: {}", other),
}
}
}
impl ::std::error::Error for Error {}
}