Back to Pocketbase

Interface _static

static/jsvm/interfaces/apis._static.html

latest2.0 KB
Original Source

Interface _static

Hierarchy

  • _static

  • _static(fsys, indexFallback): ((_arg0) => void)

Static is a handler function to serve static directory content from fsys.

If a file resource is missing and indexFallback is set, the request will be forwarded to the base index.html (useful for SPA with pretty urls).

NB! Expects the route to have a "{path...}" wildcard parameter.

Special redirects:

- if "path" is a file that ends in index.html, it is redirected to its non-index.html version (eg. /test/index.html -> /test/) - if "path" is a directory that has index.html, the index.html file is rendered, otherwise if missing - returns 404 or fallback to the root index.html if indexFallback is setCopy

Example:

fsys := os.DirFS("./pb_public") router.GET("/files/{path...}", apis.Static(fsys, false))Copy

Parameters

fsys: FS
indexFallback: boolean

Returns ((_arg0) => void)

    • (_arg0): void

Static is a handler function to serve static directory content from fsys.

If a file resource is missing and indexFallback is set, the request will be forwarded to the base index.html (useful for SPA with pretty urls).

NB! Expects the route to have a "{path...}" wildcard parameter.

Special redirects:

- if "path" is a file that ends in index.html, it is redirected to its non-index.html version (eg. /test/index.html -> /test/) - if "path" is a directory that has index.html, the index.html file is rendered, otherwise if missing - returns 404 or fallback to the root index.html if indexFallback is setCopy

Example:

fsys := os.DirFS("./pb_public") router.GET("/files/{path...}", apis.Static(fsys, false))Copy

Parameters

  - 
_arg0: RequestEvent

Returns void

Settings

Member Visibility

  • Inherited

Theme

OSLightDark

Generated using TypeDoc