Coming from a bash scripting background, Rust’s syntax is mind boggling. The code from HttpServer... to await? is a single object. Trying to figure out how it works is going to be my first task.

I will return later with results in the replies.

  // Create Http server with websocket support
  let settings_bind = settings.clone();
  HttpServer::new(move || {
    let context = LemmyContext::create(
      pool.clone(),
      chat_server.to_owned(),
      client.clone(),
      activity_queue.to_owned(),
      settings.to_owned(),
      secret.to_owned(),
    );
    let rate_limiter = rate_limiter.clone();
    App::new()
      .wrap(middleware::Logger::default())
      .app_data(Data::new(context))
      // The routes
      .configure(|cfg| api_routes::config(cfg, &rate_limiter))
      .configure(|cfg| lemmy_apub::http::routes::config(cfg, &settings))
      .configure(feeds::config)
      .configure(|cfg| images::config(cfg, &rate_limiter))
      .configure(nodeinfo::config)
      .configure(|cfg| webfinger::config(cfg, &settings))
  })
  .bind((settings_bind.bind, settings_bind.port))?
  .run()
  .await?;
  • @nutomicA
    link
    72 years ago

    This is a nice idea, but I dont think its the best way to learn. I suggest you start by reading the Rust Book, and writing some code yourself. That code in your post is using actix, so have a look at their docs and examples, and maybe also write a small web server yourself to play around with.

    • @tomltommyOPM
      link
      22 years ago

      I’m going to tackle Rust from a variety of angles, one of which is by studying Lemmy.