Sha256: db56b778f1c3cf7b22b6af7bd819d9c83b059514ade4b39c454bc13988c5a899

Contents?: true

Size: 630 Bytes

Versions: 1

Compression:

Stored size: 630 Bytes

Contents

# frozen_string_literal: true

require 'singleton'
require 'forwardable'
require 'rack'

require 'mwc'

module Mwc
  # Static assets server
  class Server
    WASM_RULE = /\.(?:wasm)\z/.freeze
    WASM_HEADER = { 'Content-Type' => 'application/wasm' }.freeze

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mwc-0.2.0 lib/mwc/server.rb