Class: Ronin::Web::CLI::Commands::Server Private

Inherits:
Ronin::Web::CLI::Command show all
Includes:
Core::CLI::Logging
Defined in:
lib/ronin/web/cli/commands/server.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Starts a web server.

Usage

ronin-web server [options]

Options

-H, --host HOST Host name or IP to bind to (Default: localhost) -p, --port PORT Port number to listen on (Default: 8000) -A, --basic-auth USER:PASSWORD Sets up Basic-Authentication -d, --dir /PATH:DIR Mounts a directory to the given PATH -f, --file /PATH:FILE Mounts a file to the given PATH -r, --root DIR Root directory to serve -R, --redirect /PATH:URL Registers a 302 Found redirect at the given PATH -h, --help Print help information

Since:

  • 1.0.0

Defined Under Namespace

Classes: App

Instance Method Summary collapse

Instance Method Details

#runObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Runs the ronin-web server command.

Since:

  • 1.0.0



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/ronin/web/cli/commands/server.rb', line 132

def run
  if options[:root]
    App.public_dir = options[:root]
  else
    App.any('*') do
      puts "#{request.request_method} #{request.path}"

      request.headers.each do |name,value|
        puts "#{name}: #{value}"
      end

      puts request.body.read
    end
  end

  log_info "Starting web server listening on #{App.bind}:#{App.port} ..."
  begin
    App.run!
  rescue Errno::EADDRINUSE => error
    log_error(error.message)
    exit(1)
  end

  log_info "Shutting down ..."
end