"activitypub 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"actix 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-files 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "actix-rt 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-web 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"actix-web-actors 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bcrypt 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
actix-web = "2.0.0"
actix-files = "0.2.1"
actix-web-actors = "2.0.0"
+actix-rt = "1.0.0"
env_logger = "0.7.1"
rand = "0.7.0"
strum = "0.17.1"
community_name: String,
}
-pub fn get_apub_community(info: Path<CommunityQuery>) -> HttpResponse<Body> {
+pub async fn get_apub_community(info: Path<CommunityQuery>) -> HttpResponse<Body> {
let connection = establish_connection();
if let Ok(community) = Community::read_from_name(&connection, info.community_name.to_owned()) {
}
}
-pub fn get_apub_community_followers(info: Path<CommunityQuery>) -> HttpResponse<Body> {
+pub async fn get_apub_community_followers(info: Path<CommunityQuery>) -> HttpResponse<Body> {
let connection = establish_connection();
if let Ok(community) = Community::read_from_name(&connection, info.community_name.to_owned()) {
user_name: String,
}
-pub fn get_apub_user(info: Path<UserQuery>) -> HttpResponse<Body> {
+pub async fn get_apub_user(info: Path<UserQuery>) -> HttpResponse<Body> {
let connection = establish_connection();
if let Ok(user) = User_::find_by_email_or_username(&connection, &info.user_name) {
use lemmy_server::db::establish_connection;
use lemmy_server::routes::{federation, feeds, index, nodeinfo, webfinger, websocket};
use lemmy_server::settings::Settings;
+use std::io;
embed_migrations!();
-fn main() {
+#[actix_rt::main]
+async fn main() -> io::Result<()> {
env_logger::init();
- let sys = actix::System::new("lemmy");
// Run the migrations from code
let conn = establish_connection();
let settings = Settings::get();
+ println!(
+ "Starting http server at {}:{}",
+ settings.bind, settings.port
+ );
+
// Create Http server with websocket support
HttpServer::new(move || {
App::new()
settings.front_end_dir.to_owned() + "/documentation",
))
})
- .bind((settings.bind, settings.port))
- .unwrap()
- .run();
-
- println!("Started http server at {}:{}", settings.bind, settings.port);
- let _ = sys.run();
+ .bind((settings.bind, settings.port))?
+ .run()
+ .await
}
.route("/feeds/all.xml", web::get().to(feeds::get_all_feed));
}
-fn get_all_feed(info: web::Query<Params>) -> HttpResponse<Body> {
+async fn get_all_feed(info: web::Query<Params>) -> HttpResponse<Body> {
let sort_type = match get_sort_type(info) {
Ok(sort_type) => sort_type,
Err(_) => return HttpResponse::BadRequest().finish(),
}
}
-fn get_feed(path: web::Path<(String, String)>, info: web::Query<Params>) -> HttpResponse<Body> {
+async fn get_feed(
+ path: web::Path<(String, String)>,
+ info: web::Query<Params>,
+) -> HttpResponse<Body> {
let sort_type = match get_sort_type(info) {
Ok(sort_type) => sort_type,
Err(_) => return HttpResponse::BadRequest().finish(),
.route("/.well-known/nodeinfo", web::get().to(node_info_well_known));
}
-pub fn node_info_well_known() -> HttpResponse<Body> {
+async fn node_info_well_known() -> HttpResponse<Body> {
let json = json!({
"links": {
"rel": "http://nodeinfo.diaspora.software/ns/schema/2.0",
.body(json.to_string())
}
-fn node_info() -> HttpResponse<Body> {
+async fn node_info() -> HttpResponse<Body> {
let conn = establish_connection();
let site_view = match SiteView::read(&conn) {
Ok(site_view) => site_view,
///
/// You can also view the webfinger response that Mastodon sends:
/// https://radical.town/.well-known/webfinger?resource=acct:felix@radical.town
-fn get_webfinger_response(info: Query<Params>) -> HttpResponse<Body> {
+async fn get_webfinger_response(info: Query<Params>) -> HttpResponse<Body> {
let regex_parsed = WEBFINGER_COMMUNITY_REGEX
.captures(&info.resource)
.map(|c| c.get(1));