Next
Cowboy User Guide
Table of Contents
I. Rationale
1. The modern Web
1.1. HTTP/2
1.2. HTTP/1.1
1.3. Websocket
1.4. Long-lived requests
1.5. REST
2. Erlang and the Web
2.1. The Web is concurrent
2.2. The Web is soft real time
2.3. The Web is asynchronous
2.4. The Web is omnipresent
2.5. Learn Erlang
II. Introduction
3. Introduction
3.1. Prerequisites
3.2. Supported platforms
3.3. License
3.4. Versioning
3.5. Conventions
4. Getting started
4.1. Prerequisites
4.2. Bootstrap
4.3. Cowboy setup
4.4. Listening for connections
4.5. Handling requests
5. Flow diagram
5.1. Overview
5.2. Protocol-specific headers
5.3. Number of processes per connection
5.4. Date header
5.5. Binaries
III. Configuration
6. Listeners
6.1. Clear TCP listener
6.2. Secure TLS listener
6.3. Stopping the listener
6.4. Protocol configuration
7. Routing
7.1. Syntax
7.2. Match syntax
7.3. Constraints
7.4. Compilation
7.5. Using persistent_term
7.6. Live update
8. Constraints
8.1. Syntax
8.2. Built-in constraints
8.3. Custom constraints
IV. Handlers
9. Handlers
9.1. Plain HTTP handlers
9.2. Other handlers
9.3. Cleaning up
10. Loop handlers
10.1. Initialization
10.2. Receive loop
10.3. Streaming loop
10.4. Cleaning up
10.5. Hibernate
10.6. Idle timeout
11. Static files
11.1. Serve one file
11.2. Serve all files from a directory
11.3. Customize the mimetype detection
11.4. Generate an etag
V. Request and response
12. The Req object
12.1. Direct access
12.2. Introduction to the cowboy_req interface
12.3. Request method
12.4. HTTP version
12.5. Effective request URI
12.6. Bindings
12.7. Query parameters
12.8. Headers
12.9. Peer
13. Reading the request body
13.1. Request body presence
13.2. Request body length
13.3. Reading the body
13.4. Streaming the body
13.5. Reading a form urlencoded body
14. Sending a response
14.1. Reply
14.2. Stream reply
14.3. Preset response headers
14.4. Overriding headers
14.5. Preset response body
14.6. Sending files
14.7. Informational responses
14.8. Push
15. Using cookies
15.1. Setting cookies
15.2. Reading cookies
16. Multipart requests
16.1. Form-data
16.2. Checking for multipart messages
16.3. Reading a multipart message
16.4. Skipping unwanted parts
VI. REST
17. REST principles
17.1. REST architecture
17.2. Resources and resource identifiers
17.3. Resource representations
17.4. Self-descriptive messages
17.5. Hypermedia as the engine of application state
18. REST handlers
18.1. Initialization
18.2. Methods
18.3. Callbacks
18.4. Meta data
18.5. Response headers
19. REST flowcharts
19.1. Start
19.2. OPTIONS method
19.3. Content negotiation
19.4. GET and HEAD methods
19.5. PUT, POST and PATCH methods
19.6. DELETE method
19.7. Conditional requests
20. Designing a resource handler
20.1. The service
20.2. Type of resource handler
20.3. Collection handler
20.4. Single resource handler
20.5. The resource
20.6. Representations
20.7. Redirections
20.8. The request
20.9. OPTIONS method
20.10. GET and HEAD methods
20.11. PUT, POST and PATCH methods
20.12. DELETE methods
VII. Websocket
21. The Websocket protocol
21.1. Description
21.2. Websocket vs HTTP/2
21.3. Implementation
22. Websocket handlers
22.1. Upgrade
22.2. Subprotocol
22.3. Post-upgrade initialization
22.4. Receiving frames
22.5. Receiving Erlang messages
22.6. Sending frames
22.7. Keeping the connection alive
22.8. Limiting frame sizes
22.9. Saving memory
22.10. Closing the connection
VIII. Advanced
23. Streams
23.1. Stream handlers
23.2. Built-in handlers
24. Middlewares
24.1. Usage
24.2. Configuration
24.3. Routing middleware
24.4. Handler middleware
25. Performance
25.1. One process per connection
IX. Additional information
A. Migrating from Cowboy 2.11 to 2.12
A.1. Features added
B. Migrating from Cowboy 2.10 to 2.11
B.1. Features added
B.2. Features removed
B.3. Bugs fixed
C. Migrating from Cowboy 2.9 to 2.10
C.1. Features added
C.2. Bugs fixed
D. Migrating from Cowboy 2.8 to 2.9
D.1. Features added
D.2. Bugs fixed
E. Migrating from Cowboy 2.7 to 2.8
E.1. Features added
E.2. Experimental features added
E.3. Features modified
E.4. Bugs fixed
F. Migrating from Cowboy 2.6 to 2.7
F.1. Features added
F.2. Experimental features added
F.3. New functions
F.4. Bugs fixed
G. Migrating from Cowboy 2.5 to 2.6
G.1. Features added
G.2. Experimental features added
G.3. Bugs fixed
H. Migrating from Cowboy 2.4 to 2.5
H.1. Features added
H.2. Experimental features added
H.3. New functions
H.4. Bugs fixed
I. Migrating from Cowboy 2.3 to 2.4
I.1. Features added
I.2. Bugs fixed
J. Migrating from Cowboy 2.2 to 2.3
J.1. Features added
J.2. Bugs fixed
K. Migrating from Cowboy 2.1 to 2.2
K.1. Features added
K.2. New functions
K.3. Bugs fixed
L. Migrating from Cowboy 2.0 to 2.1
L.1. Features added
L.2. Experimental features added
L.3. Changed behaviors
L.4. New functions
L.5. Bugs fixed
M. Migrating from Cowboy 1.0 to 2.0
M.1. Compatibility
M.2. Features added
M.3. Features removed
M.4. Changed behaviors
M.5. New functions
M.6. Changed functions
M.7. Removed functions
M.8. Other changes
N. HTTP and other specifications
N.1. HTTP
N.2. URL
N.3. WebDAV
N.4. CoAP