Git Product home page Git Product logo

rest-echo's Introduction

Hello World REST Service

Simple REST Service that echos the requests back. This service runs inside a container so there is almost no overhead in getting started.

What is this sevice good for?

  • Easy test reverse proxy routes and paths.
  • Use this service as a dummy to see if request reach your service correctly.
  • Use it to test load balancers by peeking at the out and see the host/ip.
  • Use it for Hello World demo projects that respond the request back.

Start

docker run -ti --rm -p 5050:5050 vad1mo/hello-world-rest

Be patient, because it takes some time until all dependencies are downloaded and the container actually repsonses to requests.

Example

> curl localhost:5050/foo/bar
/:path1/:path2 - Hello to foo/bar ! Host:0bd595c5b46a/172.18.0.3

Usage

Send request to curl localhost:5050/xx/yy and see it bouncing back.

Responses

get {
    render "/ - Hello World! Host:${InetAddress.getLocalHost()}"
}
get(":name") {
    render "/ - Hello $pathTokens.name! Host:${InetAddress.getLocalHost()}"
}
get("/:path1/:path2") {
    render "/:path1/:path2 - Hello to $pathTokens.path1/$pathTokens.path2 ! Host:${InetAddress.getLocalHost()}"
}
get("/:path1/:path2/:path3") {
    render "/:path1/:path2/:path3 - Hello to $pathTokens.path1/$pathTokens.path2/$pathTokens.path3 ! Host:${InetAddress.getLocalHost()}"
}

Compose Example

  version: '2'
  services:
#---#
    proxy:
      image: traefik:1.3-alpine
      command: --web --docker --docker.domain=docker.localhost --logLevel=DEBUG --docker.endpoint=unix:///var/run/docker.sock
      ports:
        - 80:80
        - 443:443
      labels:
        - traefik.enable=false
      volumes:
        - /var/run/docker.sock:/var/run/docker.sock
        - /dev/null:/traefik.toml
#---#
    service_web:
      image: vad1mo/hello-world-rest
      hostname: web
      labels:
        - traefik.backend=web
        - traefik.port=5050
        - traefik.frontend.rule=Host:sample.127.0.0.1.xip.io; Path:/api/webhook, /api/token ,PathPrefix:/
        - traefik.frontend.entryPoints=http
        - traefik.frontend.priority = 1
#---#
    service_api:
      image: vad1mo/hello-world-rest
      hostname: api
      labels:
        - traefik.backend=api
        - traefik.port=5050
        - traefik.frontend.rule=Host:sample.127.0.0.1.xip.io; PathPrefix:/v2/
        - traefik.frontend.entryPoints=http
        - traefik.frontend.priority = 10

rest-echo's People

Contributors

vad1mo avatar

Watchers

James Cloos avatar  avatar

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.