about summary refs log tree commit diff
Commit message (Collapse)AuthorAgeFilesLines
* Add GetPath and GetMethod to the Match object masterFranck Cuny2013-05-122-7/+15
|
* The Match type implement an interface.Franck Cuny2013-05-121-2/+6
| | | | | The "mapping" field that contains the map of elements in the path is now private and can be accesed via the RouteParams function.
* FmtFranck Cuny2013-05-111-3/+3
|
* The response object is passed to the matching function.Franck Cuny2013-05-115-20/+17
| | | | | | Instead of letting the matching function creates the response object, it's created earlier with a default HTTP status of 200, and the object is passed to the function.
* remove the example, it does not make sense anymoreFranck Cuny2013-05-081-72/+0
|
* request and response are in web-requestFranck Cuny2013-05-081-8/+9
|
* fix importFranck Cuny2013-05-081-1/+1
|
* clean up last mention of moohFranck Cuny2013-05-081-14/+14
|
* Clean up messy path before matching a request.Franck Cuny2013-05-082-1/+22
| | | | | Try to clean up messy path (too many slashes for now) in the path before applying the Match.
* Rename the package from mooh to routerFranck Cuny2013-05-085-16/+19
|
* add build status to readmeFranck Cuny2013-05-071-1/+1
|
* Support travisFranck Cuny2013-05-071-0/+1
|
* Remove code not related to the router.Franck Cuny2013-05-066-110/+8
| | | | | | | | `foom` is now the web framework, so the code from mooh.go has been moved to that repository. The response and request are handled by the new `web-request` project, and so the code has been moved to this repository.
* Update the GetRouteList test.Franck Cuny2013-05-061-4/+0
| | | | | This test was failing because it was expecting the list to be ordered, but that's not the case.
* rename mooh to path routerFranck Cuny2013-05-061-8/+6
|
* Add a one line documentation for the public methods in the routerFranck Cuny2013-04-291-0/+11
|
* gofmtFranck Cuny2013-04-281-3/+3
|
* Generate route to respond with 405 when the HTTP method is not existing.Franck Cuny2013-04-282-3/+41
| | | | | | | When the user call `AddNotAllowed` on the router, for each path, a new route will be added for each HTTP method not existing. The new route returns a 405 HTTP error and a header containing the list of allowed HTTP methods.
* By calling AddOptions on the router, a route for OPTIONS is addedFranck Cuny2013-04-283-3/+33
| | | | | The AddOptions method on the Router creates a route to respond to the OPTIONS request, and list all the supported HTTP methods for the given route.
* `BuildRouter` return a reference to itself.Franck Cuny2013-04-282-3/+4
|
* Add a method to get the HTTP methods supported for a path.Franck Cuny2013-04-282-3/+37
|
* Add a few more methods for future introspection to the Router.Franck Cuny2013-04-282-4/+101
| | | | | | | | | | | | | | | The HasPath method check if a path is know by the router and return a boolean. The RemovePath method is useful to remove dynamically a path from the router. The GetAllRoutesByMethods returns a list of routes that match a given method. I'm not sure I'll keep all those methods available since there's no immutability on the routes, and I don't want the user to mess with them. We will see later.
* Use `knownPaths` to return the list of paths in GetRouteList.Franck Cuny2013-04-281-3/+5
|
* Update README with correct placeholders in URL.Franck Cuny2013-04-281-3/+3
|
* Placeholder in URL use the {\w+} form, not :\w+Franck Cuny2013-04-275-23/+23
| | | | | This is the format supported for URI templates (RFC 6570). We're not using it now but this is something that I consider for a near future.
* Better error message when adding twice the same route.Franck Cuny2013-04-271-1/+1
|
* Add GetRouteList to the Router.Franck Cuny2013-04-272-2/+23
| | | | This function return a list of path known by the router.
* Support default value for placeholders in route's path.Franck Cuny2013-04-272-2/+48
| | | | | | | | | | | | | | | If a route is created with a Default: &Route{ Path: "/user/:id", Defaults: map[string]string{ "id": "1", }, ... } a request for /user/ will match the route, and set the value for "id" to 1. However, the route /user will not match.
* Add exemple for validations in the README.Franck Cuny2013-04-271-0/+20
|
* Rename all instances of Dispatcher to Router.Franck Cuny2013-04-277-23/+23
|
* Rename a few files.Franck Cuny2013-04-274-203/+203
| | | | | | The dispatcher is renamed router (as for the test file) and the router_test is renamed to route_test (since that's what this file is supposed to test).
* Add benchmark for the router.Franck Cuny2013-04-271-0/+61
| | | | This is for future performances' regressions.
* I can't even spell correctly the name of my project.Franck Cuny2013-04-261-1/+1
|
* Let's start to write some documentation.Franck Cuny2013-04-261-4/+35
|
* Add Validations for URL parameters.Franck Cuny2013-04-263-20/+178
| | | | | | | | | | | | | | By adding validations, it's possible to create without ambiguity routes like "/user/:id" and "/user/:name", where the validation for the name will check that it's an number, and name is a string. A validation is not required for every key. However, you can't specify a validation for a key that does not exist in the URL. The validation use Regexp for now, and the user has to create the regexp with the function MustCompile. Some utility functions are added to easily gain information about a component, validator, etc. This will be extended more soon.
* Add build statusFranck Cuny2013-04-241-1/+1
|
* Still need to return something for go < 1.1Franck Cuny2013-04-241-0/+1
|
* Add a simple test for the dispatcherFranck Cuny2013-04-221-0/+22
|
* Routes inside the dispatcher private and check uniqueness of routesFranck Cuny2013-04-223-26/+24
| | | | | | | | There's no need to expose directly the list of routes inside the router, we will provide an interface to that later. Also, when adding a new routes, we verify that the route don't already exist, and if it's the case, we return an error.
* Add a very simple exemple to the framework.Franck Cuny2013-04-221-0/+71
|
* Change the interface to create routes.Franck Cuny2013-04-225-64/+52
| | | | | | | | | | | | Previously, to create a route, a user would call the AddRoute function, and pass three arguments (the path, the HTTP method and the function). This interface is way too limited if we need/want to expand what a route is in the future. Instead, we keep calling the AddRoute function to create a route, but this time the user pass a Route structure. The AddRoute will then apply a few transformations and connect the route to the router.
* In each route, keep a map of HTTP methods available.Franck Cuny2013-04-222-7/+5
| | | | | | By keeping a map of the HTTP methods available for a given route, we don't have to iter over a list of executors when we try to find if the request match, we can quickly check if the methos is set to true.
* Split only once per request the path in components.Franck Cuny2013-04-222-7/+9
| | | | | | | | | | | There's no need to split the URL in components every time we call the Match function on a Route. We can split it once in the dispatcher and then path the array to the function. Sadly, this makes the interface a little bit weaker, since we have to pass the HTTP method and the list instead of the full HTTP Request. I think in the future we should pass our own HTTP request object, with the split already in done in this one.
* Update and rename README.org to README.mdFranck Cuny2013-04-211-1/+1
|
* Update README.orgFranck Cuny2013-04-211-2/+1
|
* Apply gofmtFranck Cuny2013-04-212-2/+1
|
* Let's be specific about the source of the param.Franck Cuny2013-04-212-4/+4
| | | | | | Parameters can come from the URL, but also the query string or the body. For now we create a function ParamRoute to be explicit about which param we want.
* Add a simple test for the request type.Franck Cuny2013-04-211-0/+32
|
* Add a constructor to create the Request object.Franck Cuny2013-04-212-5/+9
| | | | | Some logic will be needed to create this object, it's easier to do that with a constructor.
* Normalize the name of captured components.Franck Cuny2013-04-211-2/+9
| | | | | | In the case of an optional components, the name is ":something". We need to normalize that name in order to be able to call directly "something" when needed.
* Apply gofmtFranck Cuny2013-04-212-5/+5
|
* Simplify the dispatch's workflow.Franck Cuny2013-04-215-24/+31
| | | | | | | | Forward the http.Request object to the Dispatcher's Match function, and instead of returning the route that match, return the whole Match object. We create our own Request object later in the process.
* Rename the type fn to fns and add a real type fnFranck Cuny2013-04-211-4/+5
|
* Small improvementsFranck Cuny2013-04-213-17/+11
| | | | | Don't mess with the first / for now, we will see later if we need to change it.
* Disambiguate routes when more than one match.Franck Cuny2013-04-214-14/+84
| | | | | | | | | For some path, more than one route can match. We try hard to disambiguate them, and if we can't, we return an error with the list of routes matching the request. In order to do that, the Match function needs to be able to also return an error in addition to a route.
* Add support for optional parameter in a path.Franck Cuny2013-04-212-7/+43
| | | | | | If a component in the path starts with "?:", it means that it's optional. We then store the lenght of the components without those optional parameters.
* Add very simple test to validate routes.Franck Cuny2013-04-211-0/+46
|
* The test was inversed.Franck Cuny2013-04-211-1/+1
|
* Clean the Path from useless /.Franck Cuny2013-04-212-1/+17
| | | | If a path starts with /, remove it.
* Support parameters in URL.Franck Cuny2013-04-212-19/+60
| | | | | | | | | | | | | | When creating a new route, check if the URL contains some elements with a ":" in it. If that's the case, it means that this component is a parameter. For now we consider that all the parameters are required, but in the future we should support optional parameters (starting with a ?). When dispatching a request, verify if the element in the url is a parameter and store it in the response. When a route match a request, a Match structure is returned with some information (path that matched, the route, the HTTP method, etc.).
* Very simple implementation for the framework.Franck Cuny2013-04-175-0/+158
| | | | | | | | | | | | For now the framework provide a "dispatcher" and a mechanism to add routes. The type "route" provide a constructor so some logic can be applied before creating the type. The way the dispatcher works for now is very stupid: it looks for all the registered routes, and check if it's the right HTTP method and if the patch matches. The next step is to deal with place holder in the path.
* Welcome to mooh.Franck Cuny2013-04-171-0/+12
This is yet another web framework in golang. I'm using it as a playground for ideas and concept. I've no idea if this will be one day useable.