Class: PdfMage::Api::App
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- PdfMage::Api::App
- Defined in:
- lib/pdf_mage/api/app.rb
Overview
The PdfMage Sinatra API application, which has /status and /render endpoints that you can call to render PDFs from another server over HTTPS.
Instance Method Summary collapse
Instance Method Details
#authorize! ⇒ Object
39 40 41 42 |
# File 'lib/pdf_mage/api/app.rb', line 39 def return unless CONFIG.api_secret error(401, 'Unauthorized') unless params[:secret] && params[:secret].strip == CONFIG.api_secret end |
#error(code, message) ⇒ Object
44 45 46 |
# File 'lib/pdf_mage/api/app.rb', line 44 def error(code, ) halt code, { result: 'error', message: }.to_json end |
#required_param(key) ⇒ Object
48 49 50 51 52 |
# File 'lib/pdf_mage/api/app.rb', line 48 def required_param(key) value = params[key] error(422, "Required parameter '#{key}' is missing") unless value && !value.empty? value end |