Class: Puma::App::Status

### Home Classes Methods

### In Files

- lib/puma/app/status.rb

### Parent

Object

### Methods

- ::new
- #authenticate
- #call
- #rack_response

### Files

- Manifest.txt

### Class/Module Index

Quicksearch

- Puma
- Puma::App
- Puma::App::Status
- Puma::Binder
- Puma::CLI
- Puma::Client
- Puma::Cluster
- Puma::Cluster::Worker
- Puma::CommonLogger
- Puma::ConfigDefault
- Puma::Configuration
- Puma::Configuration::ConfigMiddleware
- Puma::ConnectionError
- Puma::Const
- Puma::ControlCLI
- Puma::DSL
- Puma::Delegation
- Puma::Events
- Puma::Events::DefaultFormatter
- Puma::Events::PidFormatter
- Puma::IOBuffer
- Puma::JRubyRestart
- Puma::JavaIOBuffer
- Puma::MiniSSL
- Puma::MiniSSL::Context
- Puma::MiniSSL::SSLError
- Puma::MiniSSL::Server
- Puma::MiniSSL::Socket
- Puma::NullIO
- Puma::Rack
- Puma::Rack::Builder
- Puma::Rack::Options
- Puma::Rack::URLMap
- Puma::Reactor
- Puma::Runner
- Puma::Server
- Puma::Single
- Puma::TCPLogger
- Puma::ThreadPool
- Puma::ThreadPool::AutoTrim
- Puma::ThreadPool::Reaper
- Puma::UnsupportedOption
- Puma::Util
- Puma::Util::HeaderHash
- OpenSSL
- OpenSSL::SSL
- OpenSSL::SSL::SSLServer
- Rack
- Rack::Handler
- Rack::Handler::Puma
- IO
- IO::WaitReadable
- Object
- Process
- String

No matching classes.

# Puma::App::Status

### Constants

OK_STATUS

### Attributes

auth_token[RW]

### Public Class Methods

new(cli) click to toggle source

    # File lib/puma/app/status.rb, line 4
    def initialize(cli)
      @cli = cli
      @auth_token = nil
    end

### Public Instance Methods

authenticate(env) click to toggle source

    # File lib/puma/app/status.rb, line 12
    def authenticate(env)
      return true unless @auth_token
      env['QUERY_STRING'].to_s.split(/&;/).include?("token=#{@auth_token}")
    end

call(env) click to toggle source

    # File lib/puma/app/status.rb, line 26
    def call(env)
      unless authenticate(env)
        return rack_response(403, 'Invalid auth token', 'text/plain')
      end

      case env['PATH_INFO']
      when /\/stop$/
        @cli.stop
        return rack_response(200, OK_STATUS)

      when /\/halt$/
        @cli.halt
        return rack_response(200, OK_STATUS)

      when /\/restart$/
        @cli.restart
        return rack_response(200, OK_STATUS)

      when /\/phased-restart$/
        if !@cli.phased_restart
          return rack_response(404, '{ "error": "phased restart not available" }')
        else
          return rack_response(200, OK_STATUS)
        end

      when /\/reload-worker-directory$/
        if !@cli.reload_worker_directory
          return rack_response(404, '{ "error": "reload_worker_directory not available" }')
        else
          return rack_response(200, OK_STATUS)
        end

      when /\/stats$/
        return rack_response(200, @cli.stats)
      else
        rack_response 404, "Unsupported action", 'text/plain'
      end
    end

rack_response(status, body, content_type='application/json') click to toggle source

    # File lib/puma/app/status.rb, line 17
    def rack_response(status, body, content_type='application/json')
      headers = {
        'Content-Type' => content_type,
        'Content-Length' => body.bytesize.to_s
      }

      [status, headers, [body]]
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.