You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -11,19 +11,17 @@ LARS is a fast radix-tree based, zero allocation, HTTP router for Go. [ view ex
11
11
12
12
Why Another HTTP Router?
13
13
------------------------
14
-
Have you ever been painted into a corner by a framework, **ya me too!** and I've noticed that allot of routers out there, IMHO, are adding so much functionality that they are turning into Web Frameworks, (which is fine, frameworks are important) however, not at the expense of flexibility and configurability. So with no further ado, introducing LARS an HTTP router that can be your launching pad in creating a framework for your needs. How? Context is an interface [see example here](https://github.com/go-playground/lars/blob/master/examples/all-in-one/main.go), where you can add as little or much as you want or need and most importantly...under your control. ( I will be creating a full example app in the near future that can be used as a starting point for any project. )
14
+
Have you ever been painted into a corner by a framework, **ya me too!** and I've noticed that allot of routers out there, IMHO, are adding so much functionality that they are turning into Web Frameworks, (which is fine, frameworks are important) however, not at the expense of flexibility and configurability. So with no further ado, introducing LARS an HTTP router that can be your launching pad in creating a framework for your needs. How? Context is an interface [see example here](https://github.com/go-playground/lars/blob/master/examples/all-in-one/main.go), where you can add as little or much as you want or need and most importantly...**under your control**.
15
15
16
16
Key & Unique Features
17
17
--------------
18
18
-[x] Context is an interface allowing passing of framework/globals/application specific variables. [example](https://github.com/go-playground/lars/blob/master/examples/all-in-one/main.go)
19
-
-[x] Contains helpful logic to help prevent adding bad routes, keeping your url's consistent.
20
-
* i.e. /user/:id and /user/:user_id - the second one will fail to add letting you know that :user_id should be :id
19
+
-[x] Contains helpful logic to help prevent adding bad routes, keeping your url's consistent. i.e. /user/:id and /user/:user_id - the second one will fail to add letting you know that :user_id should be :id
21
20
-[x] Has an uber simple middleware + handler definitions!!! middleware and handlers actually have the exact same definition!
22
-
-[x] Can register custom handlers for making other middleware + handler patterns usable with this router
23
-
* best part about this is can register one for your custom context and not have to do type casting everywhere [see here](https://github.com/go-playground/lars/blob/master/examples/custom-handler/main.go)
24
-
-[x] Full support for standard/native http Handler + HandlerFunc [see here](https://github.com/go-playground/lars/blob/master/examples/native/main.go)
21
+
-[x] Can register custom handlers for making other middleware + handler patterns usable with this router; the best part about this is can register one for your custom context and not have to do type casting everywhere [see here](https://github.com/go-playground/lars/blob/master/examples/custom-handler/main.go)
22
+
-[x] Full support for standard/native http Handler + HandlerFunc + some others [see here](https://github.com/go-playground/lars/blob/master/examples/native/main.go)
25
23
* When Parsing a form call Context's ParseForm amd ParseMulipartForm functions and the URL params will be added into the Form object, just like query parameters are, so no extra work
26
-
-[x] lars uses a custom version of [httprouter](https://github.com/julienschmidt/httprouter)
24
+
-[x] lars uses a custom version of [httprouter](https://github.com/julienschmidt/httprouter) so incredibly fast and efficient.
27
25
28
26
29
27
**Note:** Since this router has only explicit matches, you can not register static routes and parameters for the same path segment. For example you can not register the patterns /user/new and /user/:user for the same request method at the same time. The routing of different request methods is independent from each other. I was initially against this, and this router allowed it in a previous version, however it nearly cost me in a big app where the dynamic param value say :type actually could have matched another static route and that's just too dangerous, so it is no longer allowed.
@@ -35,248 +33,34 @@ Use go get
35
33
36
34
```go
37
35
go get github.com/go-playground/lars
38
-
```
39
-
40
-
or to update
41
-
42
-
```go
43
-
go get -u github.com/go-playground/lars
44
-
```
45
-
46
-
Then import lars package into your code.
47
-
48
-
```go
49
-
import"github.com/go-playground/lars"
50
-
```
36
+
```
51
37
52
38
Usage
53
39
------
54
-
Below is a full example, for a simpler example [see here](https://github.com/go-playground/lars/blob/master/examples/groups/main.go)
40
+
Below is a simple example, for a full example [see here](https://github.com/go-playground/lars/blob/master/examples/all-in-one/main.go)
0 commit comments