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
// use dropshot::endpoint;
// use dropshot::ApiDescription;
// use dropshot::ConfigDropshot;
// use dropshot::ConfigLogging;
// use dropshot::ConfigLoggingLevel;
// use dropshot::HttpError;
// use dropshot::HttpResponseOk;
// use dropshot::HttpServerStarter;
// use dropshot::RequestContext;
// use dropshot::TypedBody;
// use http::StatusCode;
// use schemars::JsonSchema;
// use serde::{Deserialize, Serialize};
// use std::sync::Arc;
// use crate::{money::Currency, Checkout, CheckoutContext, CheckoutContextProvider};
// struct Context<T: CheckoutContextProvider> {
// checkout_context_provider: T,
// }
// #[derive(Serialize, Deserialize, JsonSchema)]
// struct CreateRequest {
// currency: Currency,
// }
// #[endpoint {
// method = POST,
// path = "/create",
// }]
// async fn create(
// req_ctx: Arc<RequestContext<Context>>,
// body_params: TypedBody<CreateRequest>,
// ) -> Result<HttpResponseOk<Checkout>, HttpError> {
// let params = body_params.into_inner();
// let ctx = req_ctx
// .as_ref()
// .checkout_context_provider
// .new_context()
// .await;
// // match result {
// // Err(err) => Err(HttpError {
// // status_code: StatusCode::BAD_REQUEST,
// // error_code: None,
// // external_message: err.clone(),
// // internal_message: err,
// // }),
// // Ok((game, public_state, private_states)) => Ok(HttpResponseOk(Response {
// // game,
// // public_state,
// // private_states,
// // })),
// // }
// }