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.1KB

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