hefestoapicontainer

Vistas

Puedes servir plantillas Blade usando la directiva View. Esta directiva, junto a ServeCompiledStatic, permite pasar a la vista un grupo de ficheros CSS y/o JS, y que estos carguen en una única petición comprimida y cacheada.

Directiva View

get /home:
  GetCalendar:
    directive: Pull
    host: $.memory.hefesto-localhost
    path: /datetime/calendar
    target: calendar
    cache: 3600
  View:
    directive: View
    name: home
    staticBasePath: $.map.main.staticBasePath
    css: 
      - bootstrap.min
      - home
    js:
      - bootstrap.bundle.min
      - home
    fragments:
      - navbar
      - footer
    data:
      calendar: $.memory.calendar
      domain: $.map.main.domain

Parámetros de View:

Recursos compilados (CSS/JS)

Para servir CSS y JS combinados en una sola petición, añade estos endpoints:

get /css:
  ServeCompiledStatic:
    directive: ServeCompiledStatic
    extension: css
    type: text/css
get /js:
  ServeCompiledStatic:
    directive: ServeCompiledStatic
    extension: js
    type: application/javascript

Estos endpoints reciben los parámetros r (release) y f (ficheros separados por coma) desde la URL generada automáticamente por $cssStaticFile / $jsStaticFile. Combinan todos los ficheros, los comprimen con gzip y los cachean en nginx.

Recursos estáticos individuales

Para servir imágenes, fuentes, favicon, etc., usa la directiva ServeStatic:

get /images/{id}:
  ServeStatic:
    directive: ServeStatic
    path: Assets/images
    file: $.message.pathParam.id
    type: image/jpeg
  Cache:
    directive: CacheUrl
    expirationMinutes: 120

Opciones de ServeStatic:

Para servir ficheros subidos por usuarios (almacenamiento):

get /simages/{id}:
  ServeStatic:
    directive: ServeStatic
    storage: true
    file: $.message.pathParam.id
    type: image/jpeg
    path: images
  CacheStatic:
    directive: CacheStatic
    expirationMinutes: 6000