Class: Kennedy::Server

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/kennedy/server.rb

Class Method Summary collapse

Class Method Details

.create(opts = {}) ⇒ Object

Creates a new subclass of Kennedy::Server with the given options

Options Hash (opts):

  • :encryption (Hash)

    The IV and passphrase to use when generating tickets, given as :iv and :passphrase keys in a Hash.

  • :backend (Object)

    An instance of a backend to use for authentication.

  • :session_secret (String)

    A secret for Rack::Session::Cookie to use when generating session cookies.

  • :api_keys (Hash)

    A hash of key-value pairs to use as API users/keys with HTTP basic authentication



21
22
23
24
25
26
27
28
29
30
# File 'lib/kennedy/server.rb', line 21

def self.create(opts = {})
  sc = Class.new(self)
  sc.instance_eval do
    opts.each { |k,v| set k.to_sym, v }
    raise ArgumentError, "A session secret must be set with :session_secret" unless defined?(session_secret)
    add_cookie_middleware
    set :api_keys, (defined?(api_keys) ? api_keys : {})
    set :require_ssl, (defined?(require_ssl) ? require_ssl : true)
  end
end