README.asciidoc 1.4 KB

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