/hello-world-api

Simple REST API Server which always respond 200 OK

Primary LanguageJavaScriptMIT LicenseMIT

hello-world-api

Simple REST API Server which always respond 200 OK.

TravisCI Status DockerHub Status

Description

The docker container which is run from this image start nodejs http server and respond 'application/json' payload.

Install

Pull nmatsui/hello-world-api from DockerHub:

$ docker pull nmatsui/hello-world-api

Or build nmatsui/hello-world-api from Dockerfile:

$ git clone https://github.com/nmatsui/hello-world-api.git
$ cd hello-world-api
$ docker build -t nmatsui/hello-world-api .

Usage

  1. start container

    $ docker run -d --rm -p 3000:3000 nmatsui/hello-world-api
  2. call REST API

    $ curl -i http://localhost:3000/
    HTTP/1.1 200 OK
    Content-Type: application/json
    Date: Sat, 21 Apr 2018 00:56:01 GMT
    Connection: keep-alive
    Transfer-Encoding: chunked
    
    {"message":"hello world!"}
  3. If you want to change message or listening port, give the 'MESSAGE' or 'PORT' environment variable

    $ docker run -d --rm -p 8888:8888 -e MESSAGE="FOO BAR" -e PORT="8888" nmatsui/hello-world-api
    $ curl -i http://localhost:8888/any/path
    HTTP/1.1 200 OK
    Content-Type: application/json
    Date: Sat, 21 Apr 2018 00:57:25 GMT
    Connection: keep-alive
    Transfer-Encoding: chunked
    
    {"message":"FOO BAR"}

License

MIT License

Copyright

Copyright (c) 2018 Nobuyuki Matsui nobuyuki.matsui@gmail.com