| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
Some logic will be needed to create this object, it's easier to do that
with a constructor.
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
Don't mess with the first / for now, we will see later if we need to
change it.
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
|
|
|
| |
If a path starts with /, remove it.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.).
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
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.
|