@@ -152,10 +152,6 @@ type LARS struct {
152152 // if enabled automatically handles OPTION requests; manually configured OPTION
153153 // handlers take precidence. default true
154154 automaticallyHandleOPTIONS bool
155-
156- // form decoder + once initialization
157- formDecoder * form.Decoder
158- formDecoderInit sync.Once
159155}
160156
161157// RouteMap contains a single routes full path
@@ -179,6 +175,9 @@ var (
179175 automaticOPTIONSHandler = func (c Context ) {
180176 c .Response ().WriteHeader (http .StatusOK )
181177 }
178+
179+ formDecoder * form.Decoder
180+ formDecoderInit sync.Once
182181)
183182
184183// New Creates and returns a new lars instance
@@ -197,7 +196,7 @@ func New() *LARS {
197196 http405 : []HandlerFunc {methodNotAllowedHandler },
198197 redirectTrailingSlash : true ,
199198 handleMethodNotAllowed : false ,
200- automaticallyHandleOPTIONS : true ,
199+ automaticallyHandleOPTIONS : false ,
201200 }
202201
203202 l .routeGroup .lars = l
@@ -213,19 +212,19 @@ func New() *LARS {
213212 return l
214213}
215214
215+ func initFormDecoder () {
216+ formDecoderInit .Do (func () {
217+ formDecoder = form .NewDecoder ()
218+ })
219+ }
220+
216221// BuiltInFormDecoder returns the built in form decoder github.com/go-playground/form
217222// in order for custom type to be registered.
218223func (l * LARS ) BuiltInFormDecoder () * form.Decoder {
219224
220- l .initFormDecoder ()
221-
222- return l .formDecoder
223- }
225+ initFormDecoder ()
224226
225- func (l * LARS ) initFormDecoder () {
226- l .formDecoderInit .Do (func () {
227- l .formDecoder = form .NewDecoder ()
228- })
227+ return formDecoder
229228}
230229
231230// RegisterCustomHandler registers a custom handler that gets wrapped by HandlerFunc
@@ -305,6 +304,7 @@ func (l *LARS) Serve() http.Handler {
305304
306305// Conforms to the http.Handler interface.
307306func (l * LARS ) serveHTTP (w http.ResponseWriter , r * http.Request ) {
307+
308308 c := l .pool .Get ().(* Ctx )
309309
310310 c .parent .RequestStart (w , r )
0 commit comments