Changing Route.url behavior

Written by Harminder Virk

Published on 12th January 2018

The Route.url method returns a fully qualified URL to a registered route. For example:

// register route
Route.get('user/:username', '')

// following returns - user/virk
Route.url('user/:username', { username: 'virk' })

// or resolve using controller.method name
Route.url('', { username: 'virk' })

For a specific domain

Route.url method used to take a 3rd parameter called domain. Which resolves the URL but registered under a specific domain.

  .get('post/:slug', '')

// following returns -
  { slug: 'adonis-101' },

In near future

Going forward the 3rd parameter needs to be an object over a string. The change is done in the favor of accepting more configuration options in the near future.

  { slug: 'adonis-101' },
  { domain: '' }