Skip to content

Conversation

gatopanx
Copy link
Contributor

@gatopanx gatopanx commented Dec 1, 2017

Solves #1058 #591 #257 #159.

For when you have an implicit way of accessing a namespace (headers, subdomain, or other)

My use case is:

  # NOTE: api.yourapplication.test
  namespace :api, path: '', constraints: { subdomain: 'api' ) } do
    namespace :v1 do
      # ...
    end
  end

I created a custom route formatter class:

module YourApplication
  class CustomRouteFormatter < JSONAPI::RouteFormatter
    class << self
      def format(route)
        return if route == 'api'
        super
      end

      def unformat(formatted_route)
        super
      end
    end
  end
end

and referenced it in my base controller:

      def route_formatter
        YourApplication::CustomRouteFormatter
      end

@gatopanx gatopanx force-pushed the feature/add-optional-route-formatting branch from 28b8723 to 1089a45 Compare December 1, 2017 08:09
@lgebhardt lgebhardt merged commit f2302ab into cerebris:master Jul 3, 2018
@lgebhardt
Copy link
Member

@gatopan Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants