Skip to content

codeitlikemiley/poem-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust - Poem Open API Starter Server

Build your server with Rust using poem framework.

Requirements

To build and run this project, you need the following:

The project uses a specific version of Rust, which is managed automatically using rustup. Check the rust-toolchain.toml file for the exact version.

Installation

Prerequisites

  1. Install Rust: If you don't have Rust installed, you can install it with the following command:

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  2. Clone the Repository:

    git clone https://github.com/codeitlikemiley/poem-api.git
    cd poem-api
  3. Set the Rust Toolchain:

    rustup update

Development

  1. Cargo Watch with cargo-watch

    • Install cargo-watch
    cargo install cargo-watch
    • Run Command:
    cargo watch -x run

    Note: This auto re-compiles the executable and re-run the server

Running The Server

  1. Running the Server:

    cargo run

    By Default cargo run uses .env.example ENV Variable

    PORT=3000
    HOST=127.0.0.1
    APP_SECRET=secret 

    NOTE: If you need to use other PORT you can pass in it as an ENV Variable

    PORT=8000 cargo run

Running in Production

  1. Build Release

    cargo build --release
  2. Run in Production

    APP_ENV=prod PORT=3001 APP_SECRET=SomeRandomString HOST=localhost ./target/release/poem-api

Authorizing with JWT on Swagger UI

  1. Open Swagger UI and Test the API:

    open http://localhost:3000/docs
  2. Login with username

{
    "username": "codeitlikemiley@gmail.com"
}
Image
  1. Authorization

Copy Paste the token response from Login

Then Go to any Locked Endpoint with a lock Icon

Click the Lock Icon , it would show a Modal , where you can paste the token

Image

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages