FileControllerserve a directory from the filesystem through an HTTP interface. Any route that channels requests to an
FileControllermust contain a
FileControlleris the directory on the filesystem in which request paths will be resolved against. In the above example, an HTTP request with the path
/files/image.jpgwould return the contents of the file
public/does not have a leading slash - therefore, the directory
publicmust be relative to the directory that the Conduit application was served from. In practice, this means you might have a directory structure like:
FileControllerwill resolve it relative to the filesystem root.
index.htmlwill be appended to the path when searching for a file to return.
FileControllerreturns a 404 Not Found response.
FileControllerwill set the content-type of the HTTP response based on the served files path extension. By default, it recognizes many common extensions like
.js. You may add content-types for extensions to an instance:
FileControllerwill never invoke any encoders from
CodecRegistry, but it will GZIP data if the repository allows compression for the content-type of the file (see
FileControlleralways sets the the Last-Modified header of the response to the last modified date according to the filesystem. If a request sends an If-Modified-Since header and the file has not been modified since that date, a 304 Not Modified response is sent with the appropriate headers.
Cache-Control: public, max-age=31536000
Responsewith its contents:
Response. Note that
CachePolicyonly modifies the Cache-Control header of a response. Headers like Last-Modified and ETag are not added.