Sign inSign up

keinos/http-stream-api

By keinos

Updated about 7 years ago

Sample of HTTP Stream in PHP. Customizing and usage see the repo.

Image
0

495

keinos/http-stream-api repository overview

Dockerfile of HTTP-Stream-API

Sample of a simple HTTP Stream API Server in PHP7.

docker pull keinos/http-stream-api

This is a sample of HTTP Stream API which just counts up to 10 in JSON format such as {"response":"foo","count":0}.

Usage

docker
$ # Build image
$ # or Pull image as below
$ #   $ docker pull keinos/http-stream-api
$ docker build -t http-stream .
...
$ # Run server in background (detached) and expose port 80 (container) to 8888 (host)
$ docker run --rm -d -p 8888:80 http-stream
...
$ # cURL the API Endpoint (See stream work)
$ curl http://localhost:8888/
{"response":"foo","count":0}
...
{"response":"foo","count":1}
...
{"response":"foo","count":9}
...

$ # Check only headers
$ curl -I http://localhost:8888/
HTTP/1.1 200 OK
Host: localhost:8888
Date: Mon, 27 May 2019 14:02:24 GMT
Connection: close
Access-Control-Allow-Origin: *
Content-type: application/octet-stream
Transfer-encoding: chunked

$ # Or open the html file with your browser.
$ # On macOS it would be as so:
$ open ./client_local.html
...
docker-compose
$ # Boot container with docker-compose
$ docker-compose up -d --build stream
...

$ # cURL the API Endpoint (See stream work)
$ curl http://localhost:8888/
{"response":"foo","count":0}
...
{"response":"foo","count":1}
...
{"response":"foo","count":9}
...

$ # Check only headers
$ curl -I http://localhost:8888/
HTTP/1.1 200 OK
Host: localhost:8888
Date: Mon, 27 May 2019 14:02:24 GMT
Connection: close
Access-Control-Allow-Origin: *
Content-type: application/octet-stream
Transfer-encoding: chunked

$ # Or open the html with your browser.
$ # On macOS it would be as so:
$ open ./client_local.html
...

Tag summary

Content type

Image

Digest

Size

6 MB

Last updated

about 7 years ago

docker pull keinos/http-stream-api