I have the following code:
module Heroku
using HTTP
herokuHost = HTTP.URI("https://api.heroku.com/")
addPath(uri::HTTP.URI, path::AbstractString) = merge(herokuHost, path=joinpath(herokuHost.path, path))
# apps = Heroku.addPath(Heroku.herokuHost, "apps")
macro genuri(p::Symbol)
return quote
global $p
$p = Heroku.addPath(Heroku.herokuHost, $(string(p)))
end
end
@genuri account
macro genuris(ps::Symbol...)
return quote
for p = $ps
global $p
$p = Heroku.addPath(Heroku.herokuHost, $(string(p)))
end
end
end
@genuris apps news
end
Heroku.account
The macro genuri
that deals with a single arg works fine, although I’m not sure whether I should have used $(esc(p))
instead of $p
in the assignment.
The varargs macro genuris
fails with the error LoadError: UndefVarError: p not defined
.
How can I solve this?