Skip to content

fiction.serveFile

Creates a static route with file’s content as response

Terminal window
fiction.serveFile "<file>" "<routeAlias?>" "<content type?>" "<headers?>"
ArgumentDescriptionTypeRequired
$1File to hostfiletrue
$2Use $2 instead of /<file> for route namestringfalse
$3Use custom content type instead of automatically defined onestringfalse
$4Headers to append on file responseassociative arrayfalse
Terminal window
declare -A headers=([cache-control]="max-age=507000, public")
fiction.serveFile "./icon.png" "/public/icon" "image/png" "headers"