Skip to content

A simple HTTP server using Actix Web, featuring endpoints for greeting via path parameters, query parameters, and JSON payloads. This modular starter project demonstrates handling different types of requests and structuring Rust projects effectively.

License

Notifications You must be signed in to change notification settings

BurakKontas/ActixExample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ActixExample

This project is a simple HTTP server implementation using the Actix web framework. The project provides a greet service that responds to different endpoints with data received through path parameters, query parameters, and JSON payloads. The project is structured in a modular way, with the greeter_service module being used from another part of the project.

Endpoints

  • GET /{name}/{surname}

    • This endpoint receives name and surname as path parameters and responds with a greeting message.
    #[get("/{name}/{surname}")]
    pub async fn greet_path(path: web::Path<GreetPathParams>) -> impl Responder {
        let name = &path.name;
        let surname = &path.surname;
        greeter(&format!("{} {}", name, surname))
    }
  • GET /

    • This endpoint receives name and surname as as query parameters and responds with a greeting message.
      #[get("/")]
      pub async fn greet_query(params: web::Query<GreetPathParams>) -> impl Responder {
          let name = &params.name;
          let surname = &params.surname;
          greeter(&format!("{} {}", name, surname))
      }
  • POST /

    • This endpoint receives name and surname as JSON payload and responds with a greeting message.
      #[post("/")]
      pub async fn greet_json(params: web::Json<GreetPathParams>) -> impl Responder {
          let name = &params.name;
          let surname = &params.surname;
          greeter(&format!("{} {}", name, surname))
      }

Structure

  • The project is designed with modularity in mind. The greeter_service module is imported from another part of the project, demonstrating how different parts of a project can be organized and reused.

Starter Project

  • This project serves as a starter template for building more complex web applications using the Actix web framework. It provides basic examples of handling different types of requests and structuring a project in a modular way.

About

A simple HTTP server using Actix Web, featuring endpoints for greeting via path parameters, query parameters, and JSON payloads. This modular starter project demonstrates handling different types of requests and structuring Rust projects effectively.

Topics

Resources

License

Stars

Watchers

Forks

Languages