A better way of sending recorded responses

16 views
Skip to first unread message

Kit Peters

unread,
Oct 1, 2015, 2:21:02 PM10/1/15
to Mojolicious
I'm developing Mojo::UserAgent::Mockable, a drop-in replacement for Mojo::UserAgent that is capable of recording and playing back HTTP interchanges. Currently, the way I'm handling playback is by rewriting the URL to point to an internal Mojolicious instance (https://github.com/PopeFelix/Mojo-UserAgent-Mockable/blob/master/lib/Mojo/UserAgent/Mockable.pm#L117) and setting $ua->server->app to the internal application (https://github.com/PopeFelix/Mojo-UserAgent-Mockable/blob/master/lib/Mojo/UserAgent/Mockable.pm#L197)

This seems to be working well so far. However, if I test it against a local Mojolicious app (e.g. as in https://github.com/PopeFelix/Mojo-UserAgent-Mockable/blob/master/t/010_playback_local.t#L34) it of course stops working, because I've set the internal server app to something else.  Is there a better way to serve recorded responses than what I'm doing currently?  I'd like this to be able to work with both local and remote apps.

KP
Reply all
Reply to author
Forward
0 new messages