cowboy.ezdoc 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. ::: cowboy
  2. The `cowboy` module provides convenience functions for
  3. manipulating Ranch listeners.
  4. :: Types
  5. : fields() = [atom()
  6. | {atom(), cowboy_constraints:constraint() | [cowboy_constraints:constraint()]}
  7. | {atom(), cowboy_constraints:constraint() | [cowboy_constraints:constraint()], any()}]
  8. Fields for match operations. Constraint(s) and default value are optional.
  9. : http_headers() = [{binary(), iodata()}]
  10. HTTP headers as a list of key/values.
  11. : http_status() = non_neg_integer() | binary()
  12. HTTP status.
  13. A binary status can be used to set a custom message.
  14. : http_version() = 'HTTP/1.1' | 'HTTP/1.0'
  15. HTTP version.
  16. : onresponse_fun() = fun((http_status(), http_headers(),
  17. iodata(), cowboy_req:req()) -> cowboy_req:req())
  18. Fun called immediately before sending the response.
  19. It can perform any operation on the Req object, including
  20. reading the request body or replying. If a reply is sent, it
  21. overrides the reply initially sent. The callback will not be
  22. called again for the new reply.
  23. :: Exports
  24. : start_http(Ref, NbAcceptors, TransOpts, ProtoOpts) -> {ok, pid()}
  25. Types:
  26. * Ref = ranch:ref()
  27. * NbAcceptors = non_neg_integer()
  28. * TransOpts = ranch_tcp:opts()
  29. * ProtoOpts = cowboy_protocol:opts()
  30. Start listening for HTTP connections. Returns the pid for this
  31. listener's supervisor.
  32. : start_https(Ref, NbAcceptors, TransOpts, ProtoOpts) -> {ok, pid()}
  33. Types:
  34. * Ref = ranch:ref()
  35. * NbAcceptors = non_neg_integer()
  36. * TransOpts = ranch_ssl:opts()
  37. * ProtoOpts = cowboy_protocol:opts()
  38. Start listening for HTTPS connections. Returns the pid for this
  39. listener's supervisor.
  40. : start_spdy(Ref, NbAcceptors, TransOpts, ProtoOpts) -> {ok, pid()}
  41. Types:
  42. * Ref = ranch:ref()
  43. * NbAcceptors = non_neg_integer()
  44. * TransOpts = ranch_ssl:opts()
  45. * ProtoOpts = cowboy_spdy:opts()
  46. Start listening for SPDY connections. Returns the pid for this
  47. listener's supervisor.
  48. : stop_listener(Ref) -> ok | {error, not_found}
  49. Types:
  50. * Ref = ranch:ref()
  51. Stop a previously started listener.
  52. : set_env(Ref, Name, Value) -> ok
  53. Types:
  54. * Ref = ranch:ref()
  55. * Name = atom()
  56. * Value = any()
  57. Set or update an environment value for an already running listener.
  58. This will take effect on all subsequent connections.
  59. :: See also
  60. The ^"Ranch guide^http://ninenines.eu/docs/en/ranch/HEAD/guide
  61. provides detailed information about how listeners work.