@@ -82,11 +82,15 @@ public Logger getLogger() {
8282 }
8383
8484 public HTTPServer beforeInterceptor (RequestInterceptor handler ) {
85+ if (injector != null )
86+ injector .inject (handler );
8587 beforeInterceptors .add (handler );
8688 return this ;
8789 }
8890
8991 public HTTPServer routeAutoInjector (RouteAutoInjector injector ) {
92+ if (this .injector != null )
93+ this .injector .inject (injector );
9094 routeAutoInjectors .add (injector );
9195 return this ;
9296 }
@@ -148,6 +152,8 @@ public HTTPServer staticResourceDirectory(String pathPrefix, ClassLoader classLo
148152 }
149153
150154 public HTTPServer staticHandler (String pathPrefix , StaticFileHandler handler ) {
155+ if (injector != null )
156+ injector .inject (handler );
151157 return get (pathPrefix + (pathPrefix .endsWith ("/" ) ? "" : "/" ) + "{*:path}" , handler );
152158 }
153159
@@ -160,16 +166,28 @@ public HTTPServer afterDelete(String pattern, AfterRequestHandler... handlers) {
160166 }
161167
162168 public HTTPServer route (HttpMethod method , String pattern , RequestHandler ... handlers ) {
169+ if (injector != null ) {
170+ for (RequestHandler handler : handlers )
171+ injector .inject (handler );
172+ }
163173 routes .add (new Route (this , method , pattern , Arrays .asList (handlers )));
164174 return this ;
165175 }
166176
167177 public HTTPServer beforeRoute (HttpMethod method , String pattern , RequestHandler ... handlers ) {
178+ if (injector != null ) {
179+ for (RequestHandler handler : handlers )
180+ injector .inject (handler );
181+ }
168182 beforeRoutes .add (new Route (this , method , pattern , Arrays .asList (handlers )));
169183 return this ;
170184 }
171185
172186 public HTTPServer afterRoute (HttpMethod method , String pattern , AfterRequestHandler ... handlers ) {
187+ if (injector != null ) {
188+ for (AfterRequestHandler handler : handlers )
189+ injector .inject (handler );
190+ }
173191 afterRoutes .add (new Route (this , method , pattern , null ).setAfterHandlers (Arrays .asList (handlers )));
174192 return this ;
175193 }
@@ -205,35 +223,49 @@ public HTTPServer afterAny(String pattern, AfterRequestHandler... handlers) {
205223 }
206224
207225 public HTTPServer webSocket (String pattern , WebSocketHandler handler ) {
226+ if (injector != null )
227+ injector .inject (handler );
208228 return route (HttpMethod .WEBSOCKET , pattern , new InternalWebSocketRequestHandler (handler ));
209229 }
210230
211231 public HTTPServer middleware (String name , RequestHandler handler ) {
232+ if (injector != null )
233+ injector .inject (handler );
212234 beforeMiddleware .put (name , handler );
213235 return this ;
214236 }
215237
216238 public HTTPServer middleware (String name , AfterRequestHandler handler ) {
239+ if (injector != null )
240+ injector .inject (handler );
217241 afterMiddleware .put (name , handler );
218242 return this ;
219243 }
220244
221245 public HTTPServer notFound (RequestHandler handler ) {
246+ if (injector != null )
247+ injector .inject (handler );
222248 notFoundHandler = handler ;
223249 return this ;
224250 }
225251
226252 public HTTPServer routeParamTransformer (RouteParamTransformer transformer ) {
253+ if (injector != null )
254+ injector .inject (transformer );
227255 routeParamTransformers .add (transformer );
228256 return this ;
229257 }
230258
231259 public HTTPServer responseTransformer (ResponseTransformer transformer ) {
260+ if (injector != null )
261+ injector .inject (transformer );
232262 responseTransformers .add (transformer );
233263 return this ;
234264 }
235265
236266 public HTTPServer exceptionHandler (ExceptionHandler handler ) {
267+ if (injector != null )
268+ injector .inject (handler );
237269 exceptionHandler = handler ;
238270 return this ;
239271 }
0 commit comments