@@ -213,36 +213,6 @@ defmodule TestServer.Instance do
213213 { :reply , { :ok , plug } , % { state | plugs: state . plugs ++ [ plug ] } }
214214 end
215215
216- defp build_match_function ( uri , methods ) do
217- { method_match , guards } =
218- case methods do
219- [ "*" ] ->
220- { quote ( do: _ ) , true }
221-
222- methods ->
223- var = quote do: method
224- guards = quote ( do: unquote ( var ) in unquote ( methods ) )
225-
226- { var , guards }
227- end
228-
229- { _params , path_match , guards , _post_match } = Plug.Router.Utils . build_path_clause ( uri , guards )
230-
231- { match_fn , [ ] } =
232- Code . eval_quoted (
233- quote do
234- fn
235- _conn , unquote ( method_match ) , unquote ( path_match ) , _host when unquote ( guards ) -> true
236- _conn , _method , _path , _host -> false
237- end
238- end
239- )
240-
241- fn conn ->
242- match_fn . ( conn , conn . method , Plug.Router.Utils . decode_path_info! ( conn ) , conn . host )
243- end
244- end
245-
246216 def handle_call (
247217 { :register , { :websocket , { _instance , route_ref } , { :handle , options , stacktrace } } } ,
248218 _from ,
@@ -310,6 +280,36 @@ defmodule TestServer.Instance do
310280 { :reply , res , state }
311281 end
312282
283+ defp build_match_function ( uri , methods ) do
284+ { method_match , guards } =
285+ case methods do
286+ [ "*" ] ->
287+ { quote ( do: _ ) , true }
288+
289+ methods ->
290+ var = quote do: method
291+ guards = quote ( do: unquote ( var ) in unquote ( methods ) )
292+
293+ { var , guards }
294+ end
295+
296+ { _params , path_match , guards , _post_match } = Plug.Router.Utils . build_path_clause ( uri , guards )
297+
298+ { match_fn , [ ] } =
299+ Code . eval_quoted (
300+ quote do
301+ fn
302+ _conn , unquote ( method_match ) , unquote ( path_match ) , _host when unquote ( guards ) -> true
303+ _conn , _method , _path , _host -> false
304+ end
305+ end
306+ )
307+
308+ fn conn ->
309+ match_fn . ( conn , conn . method , Plug.Router.Utils . decode_path_info! ( conn ) , conn . host )
310+ end
311+ end
312+
313313 defp run_plugs ( conn , state ) do
314314 state . plugs
315315 |> case do
0 commit comments