# NOT RUN {
mkup_name <- mockup(
route(
'GET',
'^/wizard/[a-z]+$',
function(req) {
res <- response()
# An alternative to passing information
# as a request query
wizard_name <- gsub('^/wizard/', '', uri(req))
picker <- list(
title = c('The', 'Dark Lord', 'Sir'),
name = wizard_name,
of = 'of the',
adjective = c('Enduring', 'Swift', 'Red', 'Great'),
noun = c('Heavens', 'Coldness', 'Winglelings', 'Stars')
)
body(res) <- paste(
lapply(picker, function(n) n[sample(length(n), 1)]),
collapse = ' '
)
res
}
)
)
res <- mkup_name('GET', '/wizard/jenkins')
body(res)
res <- mkup_name('GET', '/wizard/merlin')
body(res)
res <- mkup_name('GET', '/wizard/sparrowhawk')
body(res)
# }
Run the code above in your browser using DataLab