Sha256: 66de28e4439c1771833d046662bdca414e6d533d55c1227471622c8235d9db3c
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 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 :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 # Need to return nil or Roda is unhappy nil end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
staticky-0.1.0 | lib/staticky/server.rb |