Sha256: f9b9e8ec919064580f0140733fcb1a6569bbaa670eac0c744970b13f302dd91f
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
# frozen_string_literal: true require "roda" require_relative "../staticky" module Staticky class Server < Roda # This runs a local development server that serves the static files # Require this in your config.ru file and run something like `rackup` to # start the server NotFound = Class.new(Staticky::Error) plugin :common_logger, Staticky.server_logger, method: :debug plugin :render, engine: "html" plugin :public plugin :not_found do raise NotFound if Staticky.env.test? Staticky.build_path.join("404.html").read end plugin :error_handler do |e| raise e if Staticky.env.test? Staticky.build_path.join("500.html").read end route do |r| Staticky.resources.each do |resource| case resource.filepath when "index.html" r.root do render(inline: resource.read) end else r.get resource.url do render(inline: resource.read) end end end r.public end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
staticky-0.1.1 | lib/staticky/server.rb |