diff --git a/src/Handlers.jl b/src/Handlers.jl index 88167960a..63fba3457 100644 --- a/src/Handlers.jl +++ b/src/Handlers.jl @@ -496,6 +496,6 @@ are expected to be stored in the `req.context[:cookies]` of the request context as implemented in the [`HTTP.Handlers.cookie_middleware`](@ref) middleware. """ -getcookies(req) = get(() => Cookie[], req.context, :cookies) +getcookies(req) = get(() -> Cookie[], req.context, :cookies) end # module diff --git a/test/handlers.jl b/test/handlers.jl index c0b7e7ff5..0602e272b 100644 --- a/test/handlers.jl +++ b/test/handlers.jl @@ -77,4 +77,8 @@ using HTTP, Test @test r(HTTP.Request("GET", "/api/widgets/abc/subwidget")) == 15 @test r(HTTP.Request("GET", "/api/widgets/abc/subwidgetname")) == 16 + cookie = HTTP.Cookie("abc", "def") + req = HTTP.Request("GET", "/") + req.context[:cookies] = [cookie] + @test HTTP.getcookies(req)[1] == cookie end