Table of Contents

Writing REST Services - Static Content

This tutorial will teach you the basics of exposing static files for clients to consume.

Prerequisites

  1. Windows 10/11
  2. Visual studio 2019/2022
  3. Phoesion Glow Blaze , with Reactor running (see getting started guide)

Sample Code

You can download the Sample Code archive from the downloads section.
This tutorial follows the 0c_StaticFile sample in the archive. (View code on GitHub)

What is Static Content

Static content refers to any file that will be publicly accessible and cannot change (until you deploy a new version of the service).
An example of static content is a JavaScript (.js) file or an image (eg. a png file) or even an html file.

How to add a file in Static Contents

To add a file as static content you must add the file under the wwwroot directory in your service directory.
Everything under the wwwroot directory will be treated as static content and will be publicly accessible!
The wwwroot's directory structure and hierarchy will be preserved.

Note

If the wwwroot folder is missing, create a new folder and name it wwwroot

Sample

For an example you can see the wwwroot directory for the Foompany.Services.SampleService2 project in the sample (1_REST).
wwwroot_Folder

How does Static Content work?

Static content will be distributed to the Prism entities (edge nodes), to be as close to the client/browser as possible. When a client/browser requests a static file for a service, the Prism will already have the file cached locally and can provide it directly, thus avoiding putting any pressure on the other entities, like the Kaleidoscope (Service bus) or Fireflies (Services).
This means for Static Content the Prisms act as a content delivery network (CDN)

Note

The Static Content system is designed for generally small files, like images, CSS and JavaScript files.
All Static Content files will be stored on the disk of each Prism node, so large files could cause problem with disk space

Accessing the Static Content files

when running the 1_REST sample you can access the files using one of the following :