Sha256: c6f7f35fbe26bbd7034b30d24481b8d8fc2a2f6e54aafee8d1789ab0e6bab0bf

Contents?: true

Size: 1.54 KB

Versions: 8

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

require "launchy"
require "rack"
require "rack/handler/puma"
require "sinatra"

require "mihari/web/helpers/json"

require "mihari/web/controllers/base_controller"

require "mihari/web/controllers/alerts_controller"
require "mihari/web/controllers/analyzers_controller"
require "mihari/web/controllers/artifacts_controller"
require "mihari/web/controllers/command_controller"
require "mihari/web/controllers/config_controller"
require "mihari/web/controllers/ip_address_controller"
require "mihari/web/controllers/sources_controller"
require "mihari/web/controllers/tags_controller"

module Mihari
  class App < Sinatra::Base
    set :root, File.dirname(__FILE__)
    set :public_folder, File.join(root, "public")

    get "/" do
      send_file File.join(settings.public_folder, "index.html")
    end

    use Mihari::Controllers::AlertsController
    use Mihari::Controllers::AnalyzersController
    use Mihari::Controllers::ArtifactsController
    use Mihari::Controllers::CommandController
    use Mihari::Controllers::ConfigController
    use Mihari::Controllers::IPAddressController
    use Mihari::Controllers::SourcesController
    use Mihari::Controllers::TagsController

    class << self
      def run!(port: 9292, host: "localhost")
        url = "http://#{host}:#{port}"

        Rack::Handler::Puma.run self, Port: port, Host: host do |server|
          Launchy.open url

          [:INT, :TERM].each do |sig|
            trap(sig) do
              server.shutdown
            end
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mihari-3.8.1 lib/mihari/web/app.rb
mihari-3.8.0 lib/mihari/web/app.rb
mihari-3.7.2 lib/mihari/web/app.rb
mihari-3.7.1 lib/mihari/web/app.rb
mihari-3.7.0 lib/mihari/web/app.rb
mihari-3.6.1 lib/mihari/web/app.rb
mihari-3.6.0 lib/mihari/web/app.rb
mihari-3.5.0 lib/mihari/web/app.rb