1REST hello world example 2======================== 3 4To try this example, you need GNU `make` and `git` in your PATH. 5 6To build the example, run the following command: 7 8``` bash 9$ make 10``` 11 12To start the release in the foreground: 13 14``` bash 15$ ./_rel/rest_hello_world_example/bin/rest_hello_world_example console 16``` 17 18Then point your browser at [http://localhost:8080](http://localhost:8080). 19 20Example output 21-------------- 22 23Request HTML: 24 25``` bash 26$ curl -i http://localhost:8080 27HTTP/1.1 200 OK 28connection: keep-alive 29server: Cowboy 30date: Fri, 28 Sep 2012 04:15:52 GMT 31content-length: 136 32content-type: text/html 33vary: Accept 34 35<html> 36<head> 37 <meta charset="utf-8"> 38 <title>REST Hello World!</title> 39</head> 40<body> 41 <p>REST Hello World as HTML!</p> 42</body> 43</html> 44``` 45 46Request JSON: 47 48``` bash 49$ curl -i -H "Accept: application/json" http://localhost:8080 50HTTP/1.1 200 OK 51connection: keep-alive 52server: Cowboy 53date: Fri, 28 Sep 2012 04:16:46 GMT 54content-length: 24 55content-type: application/json 56vary: Accept 57 58{"rest": "Hello World!"} 59``` 60 61Request plain text: 62 63``` bash 64$ curl -i -H "Accept: text/plain" http://localhost:8080 65HTTP/1.1 200 OK 66connection: keep-alive 67server: Cowboy 68date: Fri, 28 Sep 2012 04:18:35 GMT 69content-length: 25 70content-type: text/plain 71vary: Accept 72 73REST Hello World as text! 74``` 75 76Request a non acceptable content-type: 77 78``` bash 79$ curl -i -H "Accept: text/css" http://localhost:8080 80HTTP/1.1 406 Not Acceptable 81connection: keep-alive 82server: Cowboy 83date: Fri, 28 Sep 2012 04:18:51 GMT 84content-length: 0 85 86``` 87