Module: Hyperdrive::Values

Included in:
DSL, DSL::Resource, HATEOAS, Middleware::Error, Resource
Defined in:
lib/hyperdrive/values.rb

Class Method Summary collapse

Class Method Details

.default_configObject



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/hyperdrive/values.rb', line 49

def default_config
  {
    cors: default_cors_options,
    name: 'Hyperdrive API',
    description: "v#{Hyperdrive::VERSION}",
    vendor: 'hyperdrive',
    media_types: %w(hal+json json),
    per_page: 20,
    ssl: false,
    instrumenter: Hyperdrive::Instrumenters::Noop
  }.freeze
end

.default_cors_optionsObject



39
40
41
42
43
44
45
46
47
# File 'lib/hyperdrive/values.rb', line 39

def default_cors_options
  {
      origins: '*',
      allow_headers: 'Content-Type, Accept, Accept-Encoding, Authorization, If-None-Match',
      credentials: 'false',
      expose_headers: 'Allow, Cache-Control, Content-Language, Content-Type, ETag',
      max_age: 86400
  }.freeze
end

.default_headersObject



62
63
64
65
66
# File 'lib/hyperdrive/values.rb', line 62

def default_headers
  {
    'X-Powered-By' => "Hyperdrive (v#{Hyperdrive::VERSION})"
  }
end

.definable_request_methodsObject



7
8
9
# File 'lib/hyperdrive/values.rb', line 7

def definable_request_methods
  [:get, :post, :put, :patch, :delete].freeze
end

.http_request_methodsObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/hyperdrive/values.rb', line 27

def http_request_methods
  {
    'GET'     => :get,
    'HEAD'    => :head,
    'OPTIONS' => :options,
    'POST'    => :post,
    'PUT'     => :put,
    'PATCH'   => :patch,
    'DELETE'  => :delete
  }.freeze
end

.request_methodsObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/hyperdrive/values.rb', line 15

def request_methods
  {
    get:     'GET',
    head:    'HEAD',
    options: 'OPTIONS',
    post:    'POST',
    put:     'PUT',
    patch:   'PATCH',
    delete:  'DELETE'
  }.freeze
end

.supported_request_methodsObject



11
12
13
# File 'lib/hyperdrive/values.rb', line 11

def supported_request_methods
  %w(GET HEAD OPTIONS POST PUT PATCH DELETE).freeze
end