@@ -30,7 +30,7 @@ Installation
3030Use go get
3131
3232``` go
33- go get github.com /go -playground/lars
33+ go -u get github.com /go -playground/lars
3434```
3535
3636Usage
@@ -40,15 +40,14 @@ Below is a simple example, for a full example [see here](https://github.com/go-p
4040package main
4141
4242import (
43- " fmt"
43+ " fmt"
4444 " net/http"
4545
4646 " github.com/go-playground/lars"
4747 mw " github.com/go-playground/lars/examples/middleware/logging-recovery"
4848)
4949
5050func main () {
51-
5251 l := lars.New ()
5352 // LoggingAndRecovery is just an example copy paste and modify to your needs
5453 l.Use (mw.LoggingAndRecovery )
@@ -130,7 +129,6 @@ func (mc *MyContext) RequestStart(w http.ResponseWriter, r *http.Request) {
130129
131130// RequestEnd overriding
132131func (mc *MyContext ) RequestEnd () {
133-
134132 // do whatever you need on request finish, reset variables, db connections...
135133
136134 mc.Ctx .RequestEnd () // MUST be called!
@@ -151,7 +149,6 @@ func newContext(l *lars.LARS) lars.Context {
151149
152150// casts custom context and calls you custom handler so you don;t have to type cast lars.Context everywhere
153151func castCustomContext (c lars .Context , handler lars .Handler ) {
154-
155152 // could do it in all one statement, but in long form for readability
156153 h := handler.(func (*MyContext))
157154 ctx := c.(*MyContext)
@@ -160,7 +157,6 @@ func castCustomContext(c lars.Context, handler lars.Handler) {
160157}
161158
162159func main () {
163-
164160 l := lars.New ()
165161 l.RegisterContext (newContext) // all gets cached in pools for you
166162 l.RegisterCustomHandler (func (*MyContext) {}, castCustomContext)
@@ -174,7 +170,6 @@ func main() {
174170// Home ...notice the receiver is *MyContext, castCustomContext handled the type casting for us
175171// quite the time saver if you ask me.
176172func Home (c *MyContext ) {
177-
178173 c.CustomContextFunction ()
179174 ...
180175}
0 commit comments