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
extern crate pretty_env_logger; #[allow(unused_imports)] #[macro_use] extern crate log; pub struct App { pub name: String, pub frontend_url: String, pub backend_url: String, } // pub enum RequestMethod { // DELETE, // GET, // HEAD, // PATCH, // POST, // PUT, // } // // type ApiResult<A> = Result<A, String>; // // #[derive(Response)] // struct HelloResponse { // pub message: String, // } // // #[endpoint("/", POST)] // async fn hello_world() -> ApiResult<HelloResponse> { // // } // // #[derive(Entity)] // struct Note { // pub name: String, // } // // struct Session { // pub expires_at: String, // } // struct RequestContext { // pub session: Session, // pub client_ip: String, // } // #[derive(Request)] // struct CreateNoteRequest { // pub name: String, // } // #[derive(Response)] // struct CreateNoteResponse { // pub note: Note, // } // #[endpoint("/note", [PUT, POST])] // async fn create_note(request: CreateNoteRequest) -> ApiResult<CreateNoteResponse> { // log!("{:#?", request.context); // Ok(CreateNoteResponse { // note: Note { // name: "my note".to_string() // } // }) // } #[cfg(test)] mod test_configuration { use crate::*; #[test] fn app_creation() { let _app = App { name: "Tumbleweed Test App".to_string(), frontend_url: "https://www.example.com".to_string(), backend_url: "https://api.example.com".to_string(), }; } }