struct

Kozai::Assets::Asset

Inherits Struct < Value < Object

A file served straight from the binary.

Constructors

new(content : String, content_type : String)
Source

Class methods

fingerprint(content : String) : String

FNV-1a, 64-bit. Chosen because it is eight lines and needs nothing: a digest from the standard library would drag in a C library, which is exactly what this project does not do. Collisions do not matter here — the alternative to a weak checksum is no checksum at all.

Source

Instance methods

bytesize

Size in bytes.

Source
content

File contents.

Source
content_type

MIME type to send.

Source
etag

Entity tag for this content, quoted and ready to send.

NOTE: derived from the bytes, not from the version. A browser that cached an asset must be able to find out that it changed, and during development the version does not move while the file does. String#hash is unsuitable — Crystal seeds it randomly per process, so it would invalidate every cache on every restart.

Source