Class: Mwc::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/mwc/server.rb

Overview

Static assets server

Constant Summary collapse

WASM_RULE =
/\.(?:wasm)\z/.freeze
WASM_HEADER =
{ 'Content-Type' => 'application/wasm' }.freeze

Instance Method Summary collapse

Constructor Details

#initializeServer

Returns a new instance of Server.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mwc/server.rb', line 15

def initialize
  @static =
    Rack::Static.new(
      ->(_) { [404, {}, []] },
      root: 'dist', # TODO: Set by config
      index: "#{Mwc.project.name}.html",
      urls: [''],
      header_rules: [
        [WASM_RULE, WASM_HEADER]
      ]
    )
end

Instance Method Details

#call(env) ⇒ Object



28
29
30
# File 'lib/mwc/server.rb', line 28

def call(env)
  @static.call(env)
end