Skip to content

Commit 46a8b74

Browse files
joeybloggsjoeybloggs
authored andcommitted
Finalize switch to httprouter search algorithm
* Added attribution + copyright license * added note by benchmarks * removed benchmarks from repo and will be moving to go-httprouting-benchmark now that testing is complete.
1 parent 2454904 commit 46a8b74

File tree

8 files changed

+28
-773
lines changed

8 files changed

+28
-773
lines changed

LICENSE

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
1-
Copyright (c) 2015, Go Playground
2-
Copyright (c) 2015, Dean Karn <[email protected]>
3-
Copyright (c) 2013, Julien Schmidt (httprouter)
1+
The MIT License (MIT)
42

5-
All rights reserved.
3+
Copyright (c) 2015 Dean Karn <[email protected]>
64

7-
Redistribution and use in source and binary forms, with or without
8-
modification, are permitted provided that the following conditions are met:
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
911

10-
* Redistributions of source code must retain the above copyright notice, this
11-
list of conditions and the following disclaimer.
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
1214

13-
* Redistributions in binary form must reproduce the above copyright notice,
14-
this list of conditions and the following disclaimer in the documentation
15-
and/or other materials provided with the distribution.
16-
17-
* Neither the name of test nor the names of its
18-
contributors may be used to endorse or promote products derived from
19-
this software without specific prior written permission.
20-
21-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
##LARS
22
<img align="right" src="https://raw.githubusercontent.com/go-playground/lars/master/examples/README/test.gif">
3-
![Project status](https://img.shields.io/badge/version-2.0-green.svg)
3+
![Project status](https://img.shields.io/badge/version-2.1-green.svg)
44
[![Build Status](https://semaphoreci.com/api/v1/projects/4351aa2d-2f94-40be-a6ef-85c248490378/679708/badge.svg)](https://semaphoreci.com/joeybloggs/lars)
55
[![Coverage Status](https://coveralls.io/repos/github/go-playground/lars/badge.svg?branch=master)](https://coveralls.io/github/go-playground/lars?branch=master)
66
[![Go Report Card](https://goreportcard.com/badge/go-playground/lars)](https://goreportcard.com/report/go-playground/lars)
@@ -13,7 +13,7 @@ Why Another HTTP Router?
1313
------------------------
1414
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. )
1515

16-
Unique Features
16+
Key & Unique Features
1717
--------------
1818
- [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)
1919
- [x] Contains helpful logic to help prevent adding bad routes, keeping your url's consistent.
@@ -23,6 +23,7 @@ Unique Features
2323
* 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)
2424
- [x] Full support for standard/native http Handler + HandlerFunc [see here](https://github.com/go-playground/lars/blob/master/examples/native/main.go)
2525
* 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)
2627

2728

2829
**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.
@@ -293,9 +294,7 @@ Benchmarks
293294
-----------
294295
Run on MacBook Pro (Retina, 15-inch, Late 2013) 2.6 GHz Intel Core i7 16 GB 1600 MHz DDR3 using Go version go1.6 darwin/amd64
295296

296-
NOTE: you may have noticed the benchmark get a tiny bit slower since turning Context into an interface, but in the real world when
297-
using your own Context ( even if only for passing around globals ), there is a single pool that your objects are stored in so the
298-
small hit now will save you on the flip side in real world usage.
297+
NOTICE: lars uses a custom version of [httprouter](https://github.com/julienschmidt/httprouter)
299298

300299
```go
301300
go test -bench=. -benchmem=true
@@ -339,6 +338,7 @@ This package is inspired by the following
339338
- [echo](https://github.com/labstack/echo)
340339
- [gin](https://github.com/gin-gonic/gin)
341340

342-
License
341+
Licenses
343342
--------
344-
All source code is licensed under the [BSD License](https://raw.githubusercontent.com/go-playground/lars/master/LICENSE).
343+
[MIT License](https://raw.githubusercontent.com/go-playground/lars/master/LICENSE) (MIT), Copyright (c) 2015 Dean Karn
344+
[BSD License](https://raw.githubusercontent.com/julienschmidt/httprouter/master/LICENSE), Copyright (c) 2013 Julien Schmidt. All rights reserved.

benchmark_github_test.go

Lines changed: 0 additions & 291 deletions
This file was deleted.

0 commit comments

Comments
 (0)