Skip to content

Commit

Permalink
feat(admin) add multipart/form-data support to admin api (80% solution)
Browse files Browse the repository at this point in the history
  • Loading branch information
bungle committed Sep 15, 2018
1 parent 568a1b5 commit 857fbc7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
23 changes: 14 additions & 9 deletions kong/api/arguments.lua
Expand Up @@ -653,17 +653,22 @@ local function load(opts)
end

elseif options.multipart and find(content_type_lower, "multipart/form-data", 1, true) == 1 then
local pargs, err = parse_multipart(options, content_type)
if pargs then
if options.decode then
args.post = decode(pargs, options.schema)
if options.request and options.request.params_post then
args.post = decode(options.request.params_post, options.schema)

else
args.post = pargs
end
else
local pargs, err = parse_multipart(options, content_type)
if pargs then
if options.decode then
args.post = decode(pargs, options.schema)

elseif err then
log(NOTICE, err)
else
args.post = pargs
end

elseif err then
log(NOTICE, err)
end
end

else
Expand Down
4 changes: 3 additions & 1 deletion kong/api/init.lua
Expand Up @@ -11,6 +11,7 @@ local arguments = require "kong.api.arguments"
local Errors = require "kong.db.errors"


local ngx = ngx
local sub = string.sub
local find = string.find
local type = type
Expand Down Expand Up @@ -209,7 +210,8 @@ local function attach_new_db_routes(routes)
for method_name, method_handler in pairs(methods) do
local wrapped_handler = function(self)
self.args = arguments.load({
schema = schema,
schema = schema,
request = self.req,
})

return method_handler(self, singletons.db, handler_helpers)
Expand Down

0 comments on commit 857fbc7

Please sign in to comment.