adonisjs / adonis-middleware-base

Very specific code written to make middleware work with Http and Websocket server.
5 stars 0 forks source link

Arguments in middlewares #3

Open HigoRibeiro opened 5 years ago

HigoRibeiro commented 5 years ago

Hi, Today I created a middleware for testing and I passed as a simple conditional argument to be tested with the acler library, but before testing on a simple console.log I realized that my arguments were not coming as expected, I called the middleware 'meu' and I passed the following arguments (administrator || moderator). meu:(administrator || moderator)

As a direct result that comes from the parameters I had an array ['(administrator']

Apparently this occurs due to the haye library parsing.

Is there a way to solve this?

RomainLanz commented 5 years ago

Hey @HigoRibeiro! 👋

The arguments need to be separated by a coma and you don't need parenthesis.

// Wrong
meu:(administrator || moderator)

// Correct
meu:administrator,moderator
HigoRibeiro commented 5 years ago

Hi @RomainLanz !! I understood it, but as I said when I use the acler I need to use that structure meu:(administrator || moderator) and it's impossible, because haye library, I type raw string.

Tranks!!

RomainLanz commented 5 years ago

Maybe we could send also the raw string to the middleware.

Let see what @thetutlage think about the idea.