Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use of @eval inhibits performance #747

Closed
vtjnash opened this issue Sep 1, 2021 · 1 comment · Fixed by #812
Closed

use of @eval inhibits performance #747

vtjnash opened this issue Sep 1, 2021 · 1 comment · Fixed by #812
Labels
server About our HTTP server

Comments

@vtjnash
Copy link
Member

vtjnash commented Sep 1, 2021

This code should not use @eval, since changing the dispatch table can have poorly-controlled side effects:

HTTP.jl/src/Handlers.jl

Lines 410 to 417 in 209f10e

@eval function HTTP.Handlers.gethandler(r::$(Expr(:$, :(typeof($router)))),
::(HTTP.Handlers.gh($method)),
::(HTTP.Handlers.gh($scheme)),
::(HTTP.Handlers.gh($host)),
$(Expr(:$, vals)),
args...)
return $(Expr(:$, handler)) isa HTTP.Handler ? $(Expr(:$, handler)) : HTTP.Handlers.RequestHandlerFunction($(Expr(:$, handler)))
end

@eliascarv
Copy link

I'm dealing with issues generated by this function.

using HTTP

const router = HTTP.Router()

function test_register(router, method, path, handler)
    HTTP.@register(router, method, path, handler)
end

function test_handler(req::HTTP.Request)
    return HTTP.Response(200, "test")
end

test_register(router, "GET", "/test", test_handler)
ERROR: LoadError: UndefVarError: method not defined
Stacktrace:
 [1] top-level scope
   @ none:1
in expression starting at c:\Users\User\Documents\Elias\HTTP\test.jl:13

@quinnj quinnj mentioned this issue Mar 6, 2022
12 tasks
@fonsp fonsp added the server About our HTTP server label Mar 16, 2022
@fonsp fonsp linked a pull request Mar 16, 2022 that will close this issue
@fonsp fonsp closed this as completed Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
server About our HTTP server
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants