I achieved exactly that this way:
for (var { source, destination } of redirects) {
if (source.test(request.uri)) {
request.uri = request.uri.replace(source, destination);
...
...
return {
status: '301',
statusDescription: 'Moved Permanently',
headers: {
location: [{ value: request.uri }]