Sha256: 422d78d99f5417442553681a361751a9a71d3cc81d6243050d8249a7498cd15c

Contents?: true

Size: 1.76 KB

Versions: 1

Compression:

Stored size: 1.76 KB

Contents

# frozen_string_literal: true
#
# ronin-web-server - A custom Ruby web server based on Sinatra.
#
# Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
#
# ronin-web-server is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ronin-web-server is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ronin-web-server.  If not, see <https://www.gnu.org/licenses/>.
#

require 'ronin/web/server/base'
require 'ronin/web/server/app'

module Ronin
  #
  # Namespace for [ronin-web].
  #
  # [ronin-web]: https://github.com/ronin-rb/ronin-web#readme
  #
  module Web
    #
    # Returns the Ronin Web Server.
    #
    # @param [Hash] options
    #   Additional options.
    #
    # @yield [server]
    #   If a block is given, it will be passed the current web server.
    #
    # @yieldparam [Server::App]
    #   The current web server class.
    #
    # @return [Server::App]
    #   The current web server class.
    #
    # @example
    #   Web.server do
    #     get '/hello' do
    #       'world'
    #     end
    #   end
    #
    # @see Server::Base.run!
    #
    # @api public
    #
    def self.server(options={},&block)
      unless @server
        @server = Server::App
        @server.run!(options.merge(background: true))
      end

      @server.class_eval(&block) if block
      return @server
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ronin-web-server-0.1.1 lib/ronin/web/server.rb