Skip to content

4rjunc/rustjokes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🃏 Rustacean Jokes API 🦀

Project Overview

A fun Rust-based microservice that serves random tech and programmer jokes using Actix Web and Shuttle for deployment.

Features

  • 🌐 Simple REST API
  • 🎲 Random joke generator
  • 🚀 Easy deployment with Shuttle
  • 🔤 Full emoji support

Prerequisites

  • Rust (latest stable version)
  • Cargo
  • shuttle-cli (cargo install shuttle-cli)

Project Structure

rustjokes/
│
├── Cargo.toml
├── src/
│   └── main.rs
└── jokes.json

Installation

  1. Clone the repository:
git clone https://github.com/4rjunc/rustjokes.git
cd rustjokes
  1. Install dependencies:
cargo build

Running Locally

cargo shuttle run

Endpoints

1. Home Endpoint

  • URL: /
  • Method: GET
  • Response: "hello rustaceans! 🦀"

2. Joke Endpoint

  • URL: /joke
  • Method: GET
  • Response: Random joke from jokes.json

Sample GET Requests

Using curl

# Home endpoint
curl http://localhost:8000/

# Hosted home endpoint
curl https://rustjokes-jk76.shuttle.app

# Joke endpoint
curl http://localhost:8000/joke

# Hosted joke endpoint
curl https://rustjokes-jk76.shuttle.app/joke

Using httpie

# Home endpoint
http GET http://localhost:8000/

# Hosted home endpoint
http https://rustjokes-jk76.shuttle.app

# Joke endpoint
http GET http://localhost:8000/joke

# Hosted joke endpoint
http https://rustjokes-jk76.shuttle.app/joke

Example Response for Joke Endpoint

Why do programmers prefer dark mode? Because light attracts bugs! 🐞🌚

Deployment

Deploy using Shuttle:

shuttle deploy

Dependencies

  • actix-web: Web framework
  • rand: Random selection
  • serde: JSON serialization
  • shuttle-actix-web: Deployment platform

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Your Name - @4rjunc

Project Link: https://github.com/4rjunc/rustjokes

About

simple rust server which respond with random jokes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages