Class: Landable::ApiController

Inherits:
ApplicationController show all
Defined in:
app/controllers/landable/api_controller.rb

Constant Summary collapse

API_MEDIA_REGEX =

here’s looking at you, developer.github.com/v3/media/ mime type matching is still handled by rails - see lib/landable/mime_types.rb

%r{^application\/vnd\.landable(\.v(?<version>[\w\-]+))?(\.(?<param>(?:[\w\-]+)))?(\+(?<format>[\w\-]+))?}

Instance Method Summary collapse

Instance Method Details

#api_mediaObject



48
49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/landable/api_controller.rb', line 48

def api_media
  @api_media ||= begin
    accept = request.headers['Accept'].match(API_MEDIA_REGEX) || {}

    {
      version: Landable::VERSION::STRING,
      format:  request.format.symbol,
      param:   accept['param'].presence
    }
  end
end