routes.rb 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. Rails.application.routes.draw do
  2. # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
  3. JsonApp = if defined?(Falcon) || defined?(Puma) || defined?(Agoo)
  4. ->(env) do
  5. [200,
  6. {
  7. 'Server' => 'Rails',
  8. 'Content-Type' => 'application/json',
  9. 'Date' => Time.now.httpdate,
  10. },
  11. [{ 'message' => 'Hello, World!' }.to_json]]
  12. end
  13. else
  14. ->(env) do
  15. [200,
  16. {
  17. 'Server' => 'Rails',
  18. 'Content-Type' => 'application/json'
  19. },
  20. [{ 'message' => 'Hello, World!' }.to_json]]
  21. end
  22. end
  23. PlaintextApp = if defined?(Falcon) || defined?(Puma) || defined?(Agoo)
  24. ->(env) do
  25. [200,
  26. {
  27. 'Server' => 'Rails',
  28. 'Content-Type' => 'text/plain',
  29. 'Date' => Time.now.httpdate
  30. },
  31. ['Hello, World!']]
  32. end
  33. else
  34. ->(env) do
  35. [200,
  36. {
  37. 'Server' => 'Rails',
  38. 'Content-Type' => 'text/plain'
  39. },
  40. ['Hello, World!']]
  41. end
  42. end
  43. get "json", to: JsonApp
  44. get "db", to: "hello_world#db"
  45. get "queries", to: "hello_world#query"
  46. get "fortunes", to: "fortunes#index"
  47. get "updates", to: "hello_world#update"
  48. get "plaintext", to: PlaintextApp
  49. get "cached", to: "hello_world#cached_query"
  50. end