Giter VIP home page Giter VIP logo

teapot's Introduction

๐Ÿซ– teapot

A super simple dummy server for testing HTTP clients. Zero dependencies.

Installation

cargo install --git https://github.com/mre/teapot.git

Usage

teapot

This will always respond with a 200; no matter what.
You can configure the port with the PORT environment variable.

PORT=8080 teapot

Credits

Based on mockserver by takakawa.

teapot's People

Contributors

mre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

icodein

teapot's Issues

Make responses configurable through TOML

Example

[[route]]
matches = "/"
response = "static/index.html"

[[route]]
matches = "/:usr"
response = "static/hello.html"

[fallback]
response = "teapot"

The responses would receive the matching template variables.
So static/hello.html would get a {{usr}} variable.

teapot would be a well-known preset . ๐Ÿ˜‰

Collaboration

I'm probably not gonna add the functionality in the foreseeable future, but it could be a fun
exercise for someone looking for a little project.
So if someone wants to work on this, please feel free to add a comment here.

Here's how I would do it:

Add axum or another web framework as a dependency.
Write a serde-toml-based parser for the routing format.
Set up dynamic routes from the TOML config in the web-framework. (I don't know if this is possible with Axum)

Open for other solutions, though.

Credits

In 7d271ba#r89222702 @aszlig and me started a discussion about server responses. I decided to move it here so that the idea doesn't get lost.

binserve has such functionality, even though I prefer TOML as a configuration language. They also don't provide any fallback route (or presets) as far as I can tell.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.