Sha256: fd8ecb069c1e9623758e9b2d2397b6d6c0ec83a4889b0ab40aa4e82c83ff7708
Contents?: true
Size: 953 Bytes
Versions: 13
Compression:
Stored size: 953 Bytes
Contents
# typed: false # frozen_string_literal: true require "openapi_first" module PlugApp module Middleware # frozen_string_literal: true # Rack::NotFound is a default endpoint. Optionally initialize with the # path to a custom 404 page, to override the standard response body. # # Examples: # # Serve default 404 response: # run Rack::NotFound.new # # Serve a custom 404 page: # run Rack::NotFound.new('path/to/your/404.html') class NotFound F = ::File def initialize(path = nil, content_type = "text/html") if path.nil? @content = "Not found\n" else @content = F.read(path) @content = F.read(path) end @length = @content.bytesize.to_s @content_type = content_type end def call(env) [404, { "Content-Type" => @content_type, "Content-Length" => @length }, [@content]] end end end end
Version data entries
13 entries across 13 versions & 1 rubygems