-
Notifications
You must be signed in to change notification settings - Fork 3
Static Files
Osiris can be configured to serve static files. A staticFiles block in the API definition specifies the path from which static files are served:
api<MyComponentsProvider> {
staticFiles {
path = "/public"
}
}In the example above, any requests to the API starting /public will be handled by serving a static file from an S3 bucket. For example, a request to /public/foo.html will return the file foo.html from the S3 bucket and /public/bar/baz.html will return the file bar/baz.html from the bucket.
Static files should be created in the directory src/main/static. Any files in this directory will be uploaded to S3 during deployment. Static files can be uploaded from a different directory by specifying staticFilesDirectory in the plugin configuration in pom.xml.
An S3 bucket named <app name>-static-files-<AWS account ID> is created as part of the deployment process. The AWS account ID is used in the bucket name to ensure it is globally unique.
A different S3 bucket can be used by specifying the bucket name in the application configuration. The property name is staticFilesBucket. If this property is specified the bucket will no be created. It is assumed this is an existing bucket that isn't owned by Osiris.
An index file can be specified in the staticFiles block:
api<MyComponentsProvider> {
staticFiles {
path = "/public"
indexFile = "index.html"
}
}The index file is returned for requests to the static files endpoint that don't specify any file. For example a request to /public or /public/ on the API above will return the contents of the file index.html