The backend of a gist server written in Rust
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.rs 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #![feature(proc_macro_hygiene, decl_macro)]
  2. extern crate chrono;
  3. extern crate crypto;
  4. #[macro_use]
  5. extern crate diesel;
  6. extern crate dotenv;
  7. extern crate htmlescape;
  8. extern crate r2d2;
  9. extern crate r2d2_diesel;
  10. #[macro_use]
  11. extern crate rocket;
  12. extern crate rocket_contrib;
  13. #[macro_use]
  14. extern crate serde_derive;
  15. extern crate syntect;
  16. use dotenv::dotenv;
  17. use rocket_contrib::serve::StaticFiles;
  18. use rocket_contrib::templates::Template;
  19. mod connection;
  20. mod routes;
  21. mod schema;
  22. mod snippet;
  23. use crate::routes::static_rocket_catch_info_for_bad_request;
  24. use crate::routes::static_rocket_catch_info_for_not_found;
  25. use crate::routes::static_rocket_route_info_for_create_snippet;
  26. use crate::routes::static_rocket_route_info_for_index;
  27. use crate::routes::static_rocket_route_info_for_show_raw_snippet;
  28. use crate::routes::static_rocket_route_info_for_show_snippet;
  29. fn main() {
  30. dotenv().ok();
  31. rocket::ignite()
  32. .attach(Template::fairing())
  33. .manage(connection::init_pool())
  34. .mount(
  35. "/",
  36. routes![index, show_snippet, show_raw_snippet, create_snippet],
  37. )
  38. .mount("/static", StaticFiles::from("static"))
  39. .register(catchers![bad_request, not_found])
  40. .launch();
  41. }