class Satz::Deck

Public Instance Methods

auth() { |user, pass| ... } click to toggle source

Checks the Basic Auth headers and yields user and pass if credentials are provided. Returns nil if there are no credentials or if the block returns false or nil.

Usage:

@user = auth do |user, pass|
  User.authenticate(user, pass)
end

on @user.nil? do
  res.status = 401
  reply(error: "Unauthorized")
end
# File lib/satz.rb, line 77
def auth
  basic_auth(env) { |user, pass| yield(user, pass) }
end
read() click to toggle source

Read JSON data from the POST request.

# File lib/satz.rb, line 82
def read
  Satz.serializer.load(req.body.read)
ensure
  req.body.rewind
end
reply(data) click to toggle source

Write JSON data to the response.

# File lib/satz.rb, line 89
def reply(data)
  res.json(Satz.serializer.dump(data))
end