Skip to content

Commit e8bf16b

Browse files
author
Dean Karn
authored
Fix group logic (#18)
* Correct Group logic * break up Group function Group handled 3 separate pieces of logic, which have now been broken out for clarity and ease of use into: Group - groups retaining existing middleware GroupWithMore - groups retaining middleware and adding additional GroupWithNone - groups but retains no middleware * Update Group documentation * Updated examples DIR to _examples renamed to ensure example dependencies, if any, aren't fetched during go get
1 parent 5684150 commit e8bf16b

File tree

15 files changed

+110
-43
lines changed

15 files changed

+110
-43
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
## LARS
2-
<img align="right" src="https://raw.githubusercontent.com/go-playground/lars/master/examples/README/test.gif">![Project status](https://img.shields.io/badge/version-3.7.0-green.svg)
2+
<img align="right" src="https://raw.githubusercontent.com/go-playground/lars/master/_examples/README/test.gif">![Project status](https://img.shields.io/badge/version-4.0.0-green.svg)
33
[![Build Status](https://semaphoreci.com/api/v1/projects/4351aa2d-2f94-40be-a6ef-85c248490378/679708/badge.svg)](https://semaphoreci.com/joeybloggs/lars)
44
[![Coverage Status](https://coveralls.io/repos/github/go-playground/lars/badge.svg?branch=master)](https://coveralls.io/github/go-playground/lars?branch=master)
55
[![Go Report Card](https://goreportcard.com/badge/go-playground/lars)](https://goreportcard.com/report/go-playground/lars)
66
[![GoDoc](https://godoc.org/github.com/go-playground/lars?status.svg)](https://godoc.org/github.com/go-playground/lars)
77
![License](https://img.shields.io/dub/l/vibe-d.svg)
88
[![Gitter](https://badges.gitter.im/go-playground/lars.svg)](https://gitter.im/go-playground/lars?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
99

10-
LARS is a fast radix-tree based, zero allocation, HTTP router for Go. [ view examples](https://github.com/go-playground/lars/tree/master/examples). If looking for a more pure Go solution, be sure to check out [pure](https://github.com/go-playground/pure) which is essentially a pure version of lars
10+
LARS is a fast radix-tree based, zero allocation, HTTP router for Go. [ view examples](https://github.com/go-playground/lars/tree/master/_examples). If looking for a more pure Go solution, be sure to check out [pure](https://github.com/go-playground/pure) which is essentially a pure version of lars
1111

1212
Why Another HTTP Router?
1313
------------------------
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**.
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**.
1515

1616
Key & Unique Features
1717
--------------
18-
- [x] **Context is an interface** - this allows passing of framework/globals/application specific variables. [example](https://github.com/go-playground/lars/blob/master/examples/all-in-one/main.go)
18+
- [x] **Context is an interface** - this allows passing of framework/globals/application specific variables. [example](https://github.com/go-playground/lars/blob/master/_examples/all-in-one/main.go)
1919
- [x] **Smart Route Logic** - 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
2020
- [x] **Uber simple middleware + handlers** - middleware and handlers actually have the exact same definition!
2121
- [x] **Custom Handlers** - 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] **Diverse handler support** - Full support for standard/native http Handler + HandlerFunc + some others [see here](https://github.com/go-playground/lars/blob/master/examples/native/main.go)
22+
- [x] **Diverse handler support** - Full support for standard/native http Handler + HandlerFunc + some others [see here](https://github.com/go-playground/lars/blob/master/_examples/native/main.go)
2323
* 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
2424
- [x] **Fast & Efficient** - lars uses a custom version of [httprouter](https://github.com/julienschmidt/httprouter) so incredibly fast and efficient.
2525

@@ -32,7 +32,7 @@ go get -u github.com/go-playground/lars
3232

3333
Usage
3434
------
35-
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)
35+
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)
3636
```go
3737
package main
3838

@@ -41,7 +41,7 @@ import (
4141
"net/http"
4242

4343
"github.com/go-playground/lars"
44-
mw "github.com/go-playground/lars/examples/middleware/logging-recovery"
44+
mw "github.com/go-playground/lars/_examples/middleware/logging-recovery"
4545
)
4646

4747
func main() {
@@ -100,10 +100,10 @@ contactinfo.Delete("/delete", ...)
100100

101101
// creates a group for others + inherits all middleware registered using l.Use() + adds
102102
// OtherHandler to middleware
103-
others := l.Group("/others", OtherHandler)
103+
others := l.GroupWithMore("/others", OtherHandler)
104104

105105
// creates a group for admin WITH NO MIDDLEWARE... more can be added using admin.Use()
106-
admin := l.Group("/admin",nil)
106+
admin := l.GroupWithNone("/admin")
107107
admin.Use(SomeAdminSecurityMiddleware)
108108
...
109109
```
@@ -174,7 +174,7 @@ func Home(c *MyContext) {
174174

175175
Decoding Body
176176
-------------
177-
For full example see [here](https://github.com/go-playground/lars/blob/master/examples/decode/main.go).
177+
For full example see [here](https://github.com/go-playground/lars/blob/master/_examples/decode/main.go).
178178
currently JSON, XML, FORM + Multipart Form's are support out of the box.
179179
```go
180180
// first argument denotes yes or no I would like URL query parameter fields
@@ -253,8 +253,8 @@ comply with the following rule(s):
253253

254254
* Are completely reusable by the community without modification
255255

256-
Other middleware will be listed under the examples/middleware/... folder for a quick copy/paste modify. as an example a logging or
257-
recovery middleware are very application dependent and therefore will be listed under the examples/middleware/...
256+
Other middleware will be listed under the _examples/middleware/... folder for a quick copy/paste modify. as an example a logging or
257+
recovery middleware are very application dependent and therefore will be listed under the _examples/middleware/...
258258

259259
Benchmarks
260260
-----------
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

examples/hello-world/main.go renamed to _examples/hello-world/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"net/http"
55

66
"github.com/go-playground/lars"
7-
mw "github.com/go-playground/lars/examples/middleware/logging-recovery"
7+
mw "github.com/go-playground/lars/_examples/middleware/logging-recovery"
88
)
99

1010
func main() {
File renamed without changes.

0 commit comments

Comments
 (0)