aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_router.erl
AgeCommit message (Collapse)Author
2017-06-28Fix wrong percent encoding in a router testLoïc Hoguin
2017-06-28Remove the cyrillic latin1 testLoïc Hoguin
These characters are not allowed in URI paths.
2017-06-28Fix unit tests in cowboy_router following interface changesLoïc Hoguin
2017-06-28Improve the interface for constraintsLoïc Hoguin
There are two important changes in this commit. Constraints are now producing an error tuple. This error tuple in turn can be provided to a function for formatting a human readable error message. Both the error tuple and the formatting code are controlled by and part of the constraint function. Constraints now also implement the reverse operation. When constraint functions only validate, the reverse operation will be the same as the forward operation. When they also do some conversion then the reverse operation will reverse it. Since constraints are now performing 3 different operations (forward, reverse and format_error), they now take the form of a function accepting two separate arguments. The operation is the first argument. In addition, the return value was changed to take the form of {ok, Value} | {error, Reason}. The value must be returned as-is if it was not modified.
2017-02-19Change the type of bindings from a list to a mapLoïc Hoguin
Maps make more sense because the keys are unique.
2017-01-02Welcome to 2017Loïc Hoguin
2016-06-06Router: properly handle path segmentsLoïc Hoguin
The path segments . and .. are now removed according to the rules found in RFC3986. The path segments are now percent-decoded using the correct algorithm (the one in RFC3986 and not the "query string" one).
2016-03-05Initial commit with connection/streamsLoïc Hoguin
Breaking changes with previous commit. This is a very large change, and I am giving up on making a single commit that fixes everything. More commits will follow slowly adding back features, introducing new tests and fixing the documentation. This change contains most of the work toward unifying the interface for handling both HTTP/1.1 and HTTP/2. HTTP/1.1 connections are now no longer 1 process per connection; instead by default 1 process per request is also created. This has a number of pros and cons. Because it has cons, we also allow users to use a lower-level API that acts on "streams" (requests/responses) directly at the connection process-level. If performance is a concern, one can always write a stream handler. The performance in this case will be even greater than with Cowboy 1, although all the special handlers are unavailable. When switching to Websocket, after the handler returns from init/2, Cowboy stops the stream and the Websocket protocol takes over the connection process. Websocket then calls websocket_init/2 for any additional initialization such as timers, because the process is different in init/2 and websocket_*/* functions. This however would allow us to use websocket_init/2 for sending messages on connect, instead of sending ourselves a message and be subject to races. Note that websocket_init/2 is optional. This is all a big change and while most of the tests pass, some functionality currently doesn't. SPDY is broken and will be removed soon in favor of HTTP/2. Automatic compression is currently disabled. The cowboy_req interface probably still have a few functions that need to be updated. The docs and examples do not refer the current functionality anymore. Everything will be fixed over time. Feedback is more than welcome. Open a ticket!
2015-02-01Add a test with host ending in a dot in the routerLoïc Hoguin
2014-11-07Rename 'halt' to 'stop' for better consistencyLoïc Hoguin
Now everywhere in Cowboy when we want to stop something we return a 'stop' tuple instead of one of the many choices depending on context that we had before. This particular change affects middlewares, sub protocols and REST handlers which were using 'halt' to stop processing.
2014-10-03Replace some /binary to /bits in binary pattern matchingLoïc Hoguin
We don't need the extra check for multiple of 8 bits.
2014-09-24Small tweak from erlang:error/1 to error/1Loïc Hoguin
2014-09-24Remove the error tuple return value for middlewaresLoïc Hoguin
It wasn't interesting compared to simply returning a halt tuple with an explicit reply.
2014-09-23Make routing constraints use the fields formatLoïc Hoguin
This makes routing more in line with the rest of Cowboy and allows us to use cowboy_constraints directly.
2014-09-23Breaking update of the cowboy_req interfaceLoïc Hoguin
Simplify the interface for most cowboy_req functions. They all return a single value except the four body reading functions. The reply functions now only return a Req value. Access functions do not return a Req anymore. Functions that used to cache results do not have a cache anymore. The interface for accessing query string and cookies has therefore been changed. There are now three query string functions: qs/1 provides access to the raw query string value; parse_qs/1 returns the query string as a list of key/values; match_qs/2 returns a map containing the values requested in the second argument, after applying constraints and default value. Similarly, there are two cookie functions: parse_cookies/1 and match_cookies/2. More match functions will be added in future commits. None of the functions return an error tuple anymore. It either works or crashes. Cowboy will attempt to provide an appropriate status code in the response of crashed handlers. As a result, the content decode function has its return value changed to a simple binary, and the body reading functions only return on success.
2014-03-26Remove outdated comments, all edoc, plus a few minor tweaksLoïc Hoguin
2014-03-25Make the latin1 cyrillic route tests work on R17+Loïc Hoguin
Instead of relying on the encoding of the file we now simply have list of numbers as they would be inside a latin1 file.
2014-03-10Remove cowboy_http:urldecode/1 and urlencode/1Loïc Hoguin
Use cow_qs:urldecode/1 and cow_qs:urlencode/1 instead
2014-02-06Update copyright yearsLoïc Hoguin
2013-11-08Clarify error msg for route lacking starting slashDanielle Sucher
2013-04-26Removed asserts from unit testsEgobrain
2013-03-24add iolist support to route_matchTristan Sloughter
2013-03-02Fix cowboy_router typesLoïc Hoguin
2013-02-27Fix an incorrect comment in cowboy_routerLoïc Hoguin
2013-01-25Do not transform URIs to UnicodeVladimir Dronnikov
2013-01-29If a binding is reused, we check that values are identicalLoïc Hoguin
This is more for consistency than anything.
2013-01-28Add the 'function' constraintLoïc Hoguin
2013-01-28Add the 'int' constraintLoïc Hoguin
2013-01-28New routingLoïc Hoguin
Ultimately few things change, it's mostly just a nicer syntax and slightly different expectations. The name of the value `dispatch` did not change, because the previous dispatch values will now fail if the code is not updated to using `cowboy_router:compile/1`. No constraints have been implemented in this commit.
2013-01-22Remove cowboy_dispatcherLoïc Hoguin
Types and code are moved to cowboy_router. The match/3 export from cowboy_dispatcher isn't available anymore as it is called internally.
2013-01-03Add middleware supportLoïc Hoguin
Middlewares allow customizing the request processing. All existing Cowboy project are incompatible with this commit. You need to change `{dispatch, Dispatch}` in the protocol options to `{env, [{dispatch, Dispatch}]}` to fix your code.