diff --git a/cdn/getting-started/integrate-cdn-with-fastedge.mdx b/cdn/getting-started/integrate-cdn-with-fastedge.mdx index 9555b1bc0..8626fb84d 100644 --- a/cdn/getting-started/integrate-cdn-with-fastedge.mdx +++ b/cdn/getting-started/integrate-cdn-with-fastedge.mdx @@ -1,9 +1,317 @@ --- title: "Extend CDN functionality with FastEdge" sidebarTitle: "CDN applications" -ai-navigation: Deploy FastEdge serverless compute functions at CDN edge locations to extend content delivery with custom request/response processing, origin shielding, and dynamic content generation. +ai-navigation: Integrate FastEdge CDN applications with a Gcore CDN resource to add custom request and response processing via Customer Portal or REST API. --- -import FastEdgeCDNIntegration from "/fastedge/snippets/fastedge-cdn-integration.mdx"; +import { MethodSwitch, MethodSection } from "/snippets/method-switch.jsx"; - + + + +FastEdge CDN applications run inside the CDN request pipeline and modify requests and responses before they reach the origin or client. + +A CDN resource configured for the origin is required. To create one, follow the [CDN resource](/cdn/getting-started/create-a-cdn-resource/overview) guide. + +## How it works + +The CDN runtime invokes a CDN application at five stages of the request lifecycle: + +- **On request headers (before cache):** when the CDN receives request headers, before the cache is checked. +- **On request headers (after cache):** when the CDN receives request headers, after the cache is checked. +- **On request body:** when the CDN receives the request body. +- **On response headers:** before the CDN sends response headers to the client. +- **On response body:** before the CDN sends the response body to the client. + +CDN applications are built on the [Proxy-Wasm](https://github.com/proxy-wasm/spec) specification — an open standard for WebAssembly-based proxy extensions. + +Only one FastEdge application can be attached to each processing stage. + +## Step 1. Create a FastEdge application + +

Deploy an application from a predefined template or upload a custom binary. Custom binaries must conform to the [Proxy-Wasm](https://github.com/proxy-wasm/spec) specification.

+ + + + +

A predefined template is available for JWT authentication. It verifies the JSON Web Token in the request `Authorization` header before the request reaches the origin.

+ +1. In the [Gcore Customer Portal](https://portal.gcore.com), navigate to **FastEdge**. +2. Open the **CDN Applications** page and click **Create new application**. + +![CDN Applications page with Create new application button](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-apps-page-create-app.png) + +3. In the **Create from a template** section, select **Validate JWT in Authorization header**. + +![Create from a template section showing Validate JWT template option](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/validate-jwt.png) + +4. Enter a name for the application and, optionally, a description. +5. Add the required environment variables, such as a token signing key for authentication checks. + +![JWT template configuration form with Name and environment variables fields](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-from-template-setup.png) + +6. Click **Save and deploy**. + +

The application is deployed and ready to be linked to a CDN resource.

+ +![Application overview page showing active status](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-created.png) + +

To adjust the configuration later, click **Actions** > **Edit application**.

+ +![Application overview page with Actions menu showing Edit application option](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/actions-edit-app-from-template.png) + +
+ + +

Custom implementations are available in the [FastEdge-sdk-rust examples](https://github.com/G-Core/FastEdge-sdk-rust/examples) and [proxy-wasm-sdk-as examples](https://github.com/G-Core/proxy-wasm-sdk-as/examples) repositories.

+ +1. In the [Gcore Customer Portal](https://portal.gcore.com), navigate to **FastEdge**. +2. Open the **CDN Applications** page and click **Create new application**. + +![CDN Applications page with Create new application button](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-apps-page-create-app.png) + +3. Click **Upload binary**. + +![Create application page with Upload binary card](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-apps-upload-binary.png) + +4. Select the compiled `.wasm` file. + +![File selection dialog for uploading a binary](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/upload-binary-dialog.png) + +5. Enter a name for the application and, optionally, a description. +6. Add any required environment variables as key-value pairs. For sensitive values, click **+ Add Secret** to store them in [Secrets Manager](/fastedge/secrets-manager/manage-secrets) instead. + +![Custom app configuration form with Name, environment variables, and Secrets fields](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-setup.png) + +7. Click **Save and deploy**. + +

The application is deployed and ready to be linked to a CDN resource. To adjust the configuration later, click **Actions** > **Edit application**.

+ +![Application overview page with Actions menu showing Edit application option](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/actions-edit-app.png) + +
+
+ +## Step 2. Enable FastEdge for your CDN resource + +

FastEdge can be enabled for all requests on a CDN resource, or limited to specific URL paths using CDN rules.

+ + + + +1. In the Customer Portal, navigate to **CDN**. +2. Find the resource and open its settings. + +![CDN resources list with resource settings button](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-resource-settings-button.png) + +3. Scroll to the **FastEdge apps** section and enable the toggle for the required stage. + +![CDN resource settings showing FastEdge apps section with event toggles](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-1.png) + +4. Select the application from the dropdown. + +![FastEdge apps section with On request headers enabled and application dropdown](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-2.png) + +5. (Optional) Select the **Interrupt request processing in case of error** checkbox. + + +The **Interrupt request processing in case of error** checkbox is enabled by default. When active, errors on the FastEdge side return the relevant response code to the client. When disabled, the CDN ignores the error and forwards the request to the origin. For security-sensitive applications, keep this checkbox enabled. + + +6. Click **Save**. + + + + +

URL-specific rules apply FastEdge logic only to certain paths — for example, protecting `/api/` with JWT validation while leaving other paths unaffected.

+ +1. In the Customer Portal, navigate to **CDN**. +2. Find the resource and open its settings. +3. Click **Rules** > **Create rule**. + +![CDN resource settings with Rules tab open](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-settings-rules-section.png) + +4. Click **Create blank rule**. +5. Enter a rule name. +6. In the **Match criteria** section, specify the URL paths affected by the application. +7. In the **Options** section, click **Add option**. +8. Scroll to the **FastEdge apps** section and enable the toggle for the required stage. + +![CDN resource settings showing FastEdge apps section with event toggles](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-1.png) + +9. Select the application from the dropdown. + +![FastEdge apps section with On request headers enabled and application dropdown](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-2.png) + +10. (Optional) Select the **Interrupt request processing in case of error** checkbox. + +![Add option dialog showing FastEdge apps section](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/rule-options-fastedge-app-enable.png) + + +The **Interrupt request processing in case of error** checkbox is enabled by default. When active, errors on the FastEdge side return the relevant response code to the client. When disabled, the CDN ignores the error and forwards the request to the origin. + + +11. Click **Create rule**. + +
+
+ +## Disconnect FastEdge from CDN + +

To stop FastEdge processing on a CDN resource, disable the configured toggles and save.

+ +1. In the Customer Portal, navigate to **CDN**. +2. Find the resource and open its settings. + +![CDN resources list with resource settings button](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-resource-settings-button.png) + +3. To disable FastEdge for the **whole CDN resource**, disable the toggles in the **FastEdge apps** section. +4. To disable FastEdge for **specific URL paths**, open the **Rules** page and disable the toggle for the relevant rule. +5. Click **Save changes**. + +## Delete a CDN application + + +An enabled FastEdge application linked to a CDN resource cannot be deleted. Disconnect it from the CDN resource first. + + +1. In the Customer Portal, navigate to **FastEdge**. +2. Open the **CDN Applications** page and click the three-dot icon next to the application. + +![CDN Applications list with three-dot menu open showing Delete option](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/remove-app-fstedge.png) + +3. Click **Delete**. +4. Confirm by clicking **Yes, delete**. + +![Delete app confirmation dialog](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/confirm-deletion.png) + +
+ + +FastEdge CDN applications run inside the CDN request pipeline and modify requests and responses before they reach the origin or client. + +A CDN resource configured for the origin is required. To create one, use the [Create CDN resource](/api-reference/cdn/cdn-resources/create-cdn-resource) API endpoint. + +## How it works + +The CDN runtime invokes a CDN application at five stages of the request lifecycle: + +- **on_request_headers:** when the CDN receives request headers, before cache. +- **on_request_headers_after_cache:** when the CDN receives request headers, after cache. +- **on_request_body:** when the CDN receives the request body. +- **on_response_headers:** before the CDN sends response headers to the client. +- **on_response_body:** before the CDN sends the response body to the client. + +CDN applications are built on the [Proxy-Wasm](https://github.com/proxy-wasm/spec) specification — an open standard for WebAssembly-based proxy extensions. + +Only one FastEdge application can be attached to each processing stage. + +## Step 1. Upload a binary + +

Upload the compiled `.wasm` file to the FastEdge binary store. The API automatically detects the binary type from the file contents.

+ +```bash +curl -X POST https://api.gcore.com/fastedge/v1/binaries/raw \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/octet-stream" \ + --data-binary @app.wasm +``` + +

The response includes the binary ID used in the next step:

+ +```json +{ + "id": 12345, + "api_type": "proxy-wasm" +} +``` + +

To deploy from the predefined JWT template instead, list available templates with GET https://api.gcore.com/fastedge/v1/template, note the template's `binary` field, and use that binary ID in Step 2.

+ +## Step 2. Create a FastEdge application + +

Create the application using the binary ID from Step 1. Set `status` to `1` to activate the application immediately.

+ +```bash +curl -X POST https://api.gcore.com/fastedge/v1/apps \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "my-cdn-app", + "binary": 12345, + "status": 1, + "env": { + "MY_VARIABLE": "value" + } + }' +``` + +

The response includes the application ID (`id`), which is needed to configure the CDN resource:

+ +```json +{ + "id": 67890, + "name": "my-cdn-app", + "status": 1, + "api_type": "proxy-wasm" +} +``` + +## Step 3. Enable FastEdge for your CDN resource + +

Update the CDN resource to route traffic through the FastEdge application. The `fastedge` option accepts five trigger stages — configure the ones the application handles.

+ +```bash +curl -X PATCH https://api.gcore.com/cdn/resources/RESOURCE_ID \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "options": { + "fastedge": { + "enabled": true, + "on_request_headers": { + "app_id": "67890", + "enabled": true, + "interrupt_on_error": true + } + } + } + }' +``` + +

Replace `RESOURCE_ID` with the CDN resource ID. The `interrupt_on_error` field controls behavior on error: `true` returns the FastEdge error to the client, `false` forwards the request to the origin. For security-sensitive applications, set it to `true`.

+ +

To apply FastEdge only to specific URL paths, create a CDN rule with POST https://api.gcore.com/cdn/resources/RESOURCE_ID/rules and include the `fastedge` option in the rule's `options` object.

+ +## Disable FastEdge integration + +

Set `fastedge.enabled` to `false` to stop FastEdge processing on a CDN resource:

+ +```bash +curl -X PATCH https://api.gcore.com/cdn/resources/RESOURCE_ID \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "options": { + "fastedge": { + "enabled": false + } + } + }' +``` + +## Delete a CDN application + + +An enabled FastEdge application linked to a CDN resource cannot be deleted. Disable the FastEdge integration on the CDN resource before deleting the application. + + +```bash +curl -X DELETE https://api.gcore.com/fastedge/v1/apps/APP_ID \ + -H "Authorization: APIKey $GCORE_API_KEY" +``` + +

A `204 No Content` response confirms the application was deleted.

+ +
+
diff --git a/cdn/llms.txt b/cdn/llms.txt index 5644a3f11..c56596497 100644 --- a/cdn/llms.txt +++ b/cdn/llms.txt @@ -42,7 +42,7 @@ - [Integrate CDN resource with WordPress (WP SuperCache plugin)](https://gcore.com/docs/cdn/getting-started/integrate-cdn-with-cms/wordpress/integrate-cdn-resource-with-wordpress-wp-supercache-plugin.md): Configure WP Super Cache plugin CDN integration by enabling CDN Support, entering Gcore CDN CNAME in Off-site URL field, and verifying static asset URLs are rewritten to the custom domain. - [Integrate CDN resource with X-Cart](https://gcore.com/docs/cdn/getting-started/integrate-cdn-with-cms/integrate-cdn-resource-with-x-cart.md): Configure Gcore CDN resource integration with X-Cart 4.4.x by setting CNAME record in Customer Portal and modifying smarty.php, func.files.php, function.get_category_image_url.php, and banner_rotator.tpl files to rewrite static asset URLs to CDN CNAME domain. - [Integrate CDN resource with XenForo](https://gcore.com/docs/cdn/getting-started/integrate-cdn-with-cms/integrate-cdn-resource-with-xenforo.md): Configure Gcore CDN resource integration with XenForo by editing config.php, updating Style General Settings with CDN CNAME domain, and verifying static file URLs are rewritten to the configured CNAME record. -- [Extend CDN functionality with FastEdge](https://gcore.com/docs/cdn/getting-started/integrate-cdn-with-fastedge.md): Deploy FastEdge serverless compute functions at CDN edge locations to extend content delivery with custom request/response processing, origin shielding, and dynamic content generation. +- [Extend CDN functionality with FastEdge](https://gcore.com/docs/cdn/getting-started/integrate-cdn-with-fastedge.md): Integrate FastEdge CDN applications with a Gcore CDN resource to add custom request and response processing via Customer Portal or REST API. ## Configure an origin - [Add CDN servers to the origin ACL whitelist](https://gcore.com/docs/cdn/getting-started/configure-an-origin/add-cdn-servers-to-the-origin-acl-whitelist.md): Configure origin ACL whitelist for CDN servers using HTTP headers, IP addresses, or subnets via API endpoints; HTTP header method recommended to avoid manual updates as CDN server IPs change every 30-60 minutes. diff --git a/docs.json b/docs.json index 256abee4e..467cefb2d 100644 --- a/docs.json +++ b/docs.json @@ -421,17 +421,28 @@ "group": "FastEdge", "pages": [ "fastedge", - "fastedge/getting-started", { - "group": "Create apps", + "group": "Get started", + "pages": [ + "fastedge/getting-started", + "fastedge/getting-started/setup-rust-modern", + "fastedge/getting-started/setup-rust-legacy", + "fastedge/getting-started/setup-javascript", + "fastedge/getting-started/setup-rust-cdn" + ], + "expanded": false + }, + { + "group": "Applications", "pages": [ - "fastedge/create-apps", { "group": "HTTP Applications", "pages": [ "fastedge/getting-started/create-fastedge-apps", - "fastedge/built-in-templates", - "fastedge/getting-started/build-a-rust-wasi-app" + "fastedge/render-markdown", + "fastedge/geolocation-redirect", + "fastedge/getting-started/get-started-http", + "fastedge/getting-started/call-external-api-rust" ], "expanded": false }, @@ -439,15 +450,16 @@ "group": "CDN Applications", "pages": [ "fastedge/getting-started/integrate-cdn-with-fastedge", + "fastedge/getting-started/get-started-cdn", "fastedge/getting-started/cdn-properties" ], "expanded": false - } + }, + "fastedge/manage-apps", + "fastedge/create-manage-templates" ], "expanded": false }, - "fastedge/manage-apps", - "fastedge/create-manage-templates", { "group": "Secrets Manager", "pages": [ @@ -1725,6 +1737,18 @@ } }, "redirects": [ + { + "source": "/fastedge/create-apps", + "destination": "/fastedge/getting-started/create-fastedge-apps" + }, + { + "source": "/fastedge/getting-started/build-a-rust-wasi-app", + "destination": "/fastedge/getting-started/get-started-http" + }, + { + "source": "/fastedge/built-in-templates", + "destination": "/fastedge/render-markdown" + }, { "source": "/cdn/getting-started/create-a-cdn-resource", "destination": "/cdn/getting-started/create-a-cdn-resource/overview" diff --git a/fastedge.mdx b/fastedge.mdx index 2c14a03a2..74c3943d4 100644 --- a/fastedge.mdx +++ b/fastedge.mdx @@ -1,8 +1,31 @@ --- title: FastEdge -ai-navigation: Deploy WebAssembly edge applications on Gcore CDN edge nodes using FastEdge serverless compute for HTTP request processing, A/B testing, image conversion, and custom edge logic. +ai-navigation: FastEdge is a serverless WebAssembly edge compute platform. Run Rust and JavaScript applications at every Gcore edge location — HTTP apps, CDN extensions, edge storage, secrets, and cache available at runtime. --- -FastEdge is edge compute service which allows to execute edge apps, compiled to WebAssembly, on CDN edges. +FastEdge is a serverless edge compute platform that runs WebAssembly applications on Gcore's global edge network. Applications execute at the edge node closest to the request, with no infrastructure to configure or maintain. -Read the [FastEdge overview](/fastedge/getting-started) and a [step-by-step guide on how to create FastEdge apps](/fastedge/getting-started/create-fastedge-apps). \ No newline at end of file +## Get started + +Choose a path based on what you want to build: + +- [Build an HTTP application](/fastedge/getting-started/get-started-http) — respond to HTTP requests from the edge in Rust or JavaScript +- [Build a CDN application](/fastedge/getting-started/get-started-cdn) — extend a CDN resource with custom edge logic in Rust + +## Manage applications + +- [Manage apps](/fastedge/manage-apps) — update, redeploy, and configure running applications +- [Templates](/fastedge/create-manage-templates) — create reusable application templates + +## Runtime services + +Applications have access to these services at runtime: + +- [Edge Storage](/fastedge/kv-stores/how-it-works) — globally replicated key-value store for configuration, lookup tables, and data structures +- [Cache](/fastedge/cache) — POP-local fast storage for counters, rate limits, and memoized results +- [Secrets Manager](/fastedge/secrets-manager/manage-secrets) — encrypted values and credentials available to applications at runtime + +## Reference + +- [FastEdge CLI](/fastedge/fastedge-cli) — run and test Wasm applications locally before deploying +- [Troubleshooting](/fastedge/troubleshooting) — HTTP error codes, debug logging, and platform limits diff --git a/fastedge/built-in-templates.mdx b/fastedge/built-in-templates.mdx deleted file mode 100644 index 9da84dc86..000000000 --- a/fastedge/built-in-templates.mdx +++ /dev/null @@ -1,128 +0,0 @@ ---- -title: Built-in HTTP application templates -sidebarTitle: Built-in templates -ai-navigation: Step-by-step guide for deploying FastEdge built-in HTTP application templates — Markdown renderer and Geolocation-based redirect — including environment variable configuration, real-world examples, and testing. ---- - -FastEdge includes two built-in templates for HTTP applications: **Markdown renderer** and **Geolocation-based redirect**. Templates deploy a pre-built binary without writing or compiling custom code — select a template, configure its environment variables, and the application is live on the edge in seconds. - -Both templates are available on the **Create an application** page under the **Create from a template** section. - -![Create an application page showing Upload binary and Create from a template sections with Geolocation-based redirect and Markdown renderer cards](/images/docs/fastedge/built-in-templates/create-from-template-overview.png) - -## Markdown renderer - -The Markdown renderer fetches a Markdown file from a remote HTTP source and returns it as a rendered HTML page. It's useful for publishing documentation hosted on GitHub or any static file server without a separate rendering backend. - -Every incoming request's URL path is appended to the `BASE` variable to form the source URL. A request to `https:///guides/quickstart.md` with `BASE` set to `https://raw.githubusercontent.com/org/repo/main/` fetches `https://raw.githubusercontent.com/org/repo/main/guides/quickstart.md` and returns the rendered HTML. - -### Step 1. Create the application - -

Create the application by selecting the Markdown renderer template and setting at least the BASE variable.

- -1. In the [Gcore Customer Portal](https://portal.gcore.com), navigate to **FastEdge** > **HTTP Applications** > **Applications** and click **Create new application**. - -2. Scroll to **Create from a template** and click **Markdown renderer**. - -3. Enter a **Name** for the application. The name becomes part of the deployment URL. - -4. Fill in the **Template environment variables**: - - - **BASE** (required): The root URL of the Markdown source. The application appends the incoming request's path to this value when fetching files. Set it to the directory URL where the Markdown files live, with a trailing slash. Example: `https://raw.githubusercontent.com/G-Core/FastEdge-sdk-js/main/` - - - **HEAD** (optional): Raw HTML inserted verbatim into the `` tag of every rendered page. Use it to apply a stylesheet, set a viewport meta tag, or add any other head-level markup. Example: `` - - ![Markdown renderer form with BASE required field and optional HEAD field](/images/docs/fastedge/built-in-templates/markdown-renderer-form.png) - -5. (Optional) Configure additional sections: - - - **Response headers**: static headers added to every response, such as `Cache-Control` or CORS headers. - - **Environment variables**: additional runtime key-value pairs accessible via the SDK — separate from the template-defined variables above. - - **Secrets**: encrypted values from [Secrets Manager](/fastedge/secrets-manager/manage-secrets) for sensitive data such as API keys. The app reads each secret as an environment variable using the key name set here. - - **Edge Storage**: a key-value store the app can query at the edge. Requires an existing store on the [Edge Storage](/fastedge/kv-stores/manage-kv-store) page. - -6. Click **Save and deploy**. - -

The application details page opens with the deployment URL in the format `https://-.fastedge.app`.

- -### Step 2. Test the application - -

Request any Markdown file path from the app URL and inspect the response:

- -```sh -curl -i https://-.fastedge.app/README.md -``` - -The response is an HTML document with `Content-Type: text/html`: - -``` -HTTP/1.1 200 OK -content-type: text/html; charset=utf-8 - -...

README

... -``` - -If `HEAD` is set, the injected markup appears inside ``. If the source file does not exist at the constructed URL, the app returns the upstream HTTP error code. - -

To verify the source URL the app constructs, check that `BASE` + path matches the raw file URL directly — confirm `https://raw.githubusercontent.com/org/repo/main/README.md` returns HTTP 200 before deploying.

- -## Geolocation-based redirect - -The Geolocation-based redirect detects each visitor's country from Gcore's Geo-IP data and issues an HTTP 302 redirect to the corresponding URL. It's useful for routing international visitors to regional landing pages, language-specific subdomains, or data-residency-compliant endpoints without client-side JavaScript. - -Country rules are defined as environment variables: each key is an ISO 3166-1 alpha-2 country code and the value is the redirect URL. Visitors from countries with no matching rule are sent to the `DEFAULT` URL. - -### Step 1. Create the application - -

Create the application by selecting the Geolocation-based redirect template, then configure the DEFAULT variable and country rules.

- -1. In the Customer Portal, navigate to **FastEdge** > **HTTP Applications** > **Applications** and click **Create new application**. - -2. Scroll to **Create from a template** and click **Geolocation-based redirect**. - -3. Enter a **Name** for the application. - -4. Fill in the **Template environment variables**: - - - **DEFAULT** (required): The fallback redirect URL for visitors whose country is not matched by any rule. Every deployment must have a default — without it, unmatched visitors receive an error. Example: `https://example.com/en` - - ![Geolocation-based redirect form with DEFAULT field and Response headers section](/images/docs/fastedge/built-in-templates/geolocation-redirect-form.png) - -5. Add country redirect rules in the **Environment variables** section. Each rule is one variable: - - - **Key**: ISO 3166-1 alpha-2 country code in uppercase. Example: `DE`, `FR`, `JP`, `US`. - - **Value**: The full redirect URL for visitors from that country. Example: `https://example.com/de`. - - Add as many country rules as needed. Country codes not listed here fall through to `DEFAULT`. - -6. (Optional) Configure **Response headers**, **Secrets**, and **Edge Storage** as needed. - -7. Click **Save and deploy**. - -

The application details page opens with the deployment URL.

- -### Step 2. Test the application - -

Send a request to the app URL and inspect the redirect response:

- -```sh -curl -i https://-.fastedge.app/ -``` - -When the request originates from a country with a matching rule, the response is: - -``` -HTTP/1.1 302 Found -location: https://example.com/de -``` - -When no country rule matches, the response redirects to `DEFAULT`: - -``` -HTTP/1.1 302 Found -location: https://example.com/en -``` - -

The redirect applies to all URL paths — `/pricing`, `/contact`, and `/` all redirect using the same country logic. To restrict redirects to the root path only, use a custom binary with a path check instead of this template.

- -Both templates are configured entirely through environment variables — no binary rebuild is needed to update the configuration after deployment. Country rules, redirect targets, and the Markdown source URL can all be changed from the application details page in the Customer Portal. diff --git a/fastedge/cache.mdx b/fastedge/cache.mdx index b146bcb00..9e1ad624d 100644 --- a/fastedge/cache.mdx +++ b/fastedge/cache.mdx @@ -4,25 +4,29 @@ sidebarTitle: Cache ai-navigation: Cache is a POP-local, strongly consistent key-value store available to FastEdge applications at runtime for transient state such as rate-limit counters, response memoization, and idempotency checks. It is distinct from Edge Storage, which is globally replicated and durable. --- -Cache is a fast key-value store co-located with each FastEdge POP (Point of Presence). It is intended for transient, request-time state ( counters, memoized computations, idempotency tokens ) and is available to every FastEdge application on a paid plan at runtime without needing to be created or linked in advance. +Cache is a fast key-value store co-located with each FastEdge POP (Point of Presence). It is intended for transient, request-time state — counters, memoized computations, idempotency tokens — and is available to every FastEdge application on a paid plan at runtime without needing to be created or linked in advance. -## How it works + +Cache does not need to be created or linked to your application. It is available at runtime by importing the cache module from the SDK. + -**POP-local scope**: Cache data lives inside a single POP. Writes are not replicated to other POPs, and a value written in one POP is not visible from another. Within a POP, reads and writes are strongly consistent. +## Behavior and limits -**Transient storage**: Entries are evictable and carry no durability guarantee. Values may disappear before their expiration if the POP is under memory pressure. Cache is not a substitute for persistent storage. +Cache data lives inside a single POP. Writes are not replicated to other POPs, and a value written in one location is not visible from another. Within a POP, reads and writes are strongly consistent. -**Atomic counters**: Integer counters can be incremented and decremented atomically within a POP. This makes Cache suitable for primitives such as rate limiting and fixed-window throttling. +Entries are evictable and carry no durability guarantee. A value may disappear before its expiration if the POP is under memory pressure. Cache is not a substitute for persistent storage. -**Coalesced population (JS only)**: A `getOrSet` operation prevents duplicate work within a single WASM instance — concurrent callers for the same key share one populator execution. This convenience is currently exposed by the JavaScript SDK only. +Integer values can be incremented and decremented atomically within a POP, making Cache a natural fit for rate limiting and fixed-window throttling. The `incr` function accepts a signed delta — a positive value increments, a negative value decrements. -**Bulk deletion**: `purge` removes all cache keys visible to the application; `purgePrefix` removes all keys whose names begin with a given string. Both return the number of keys deleted. Because cache is shared across all applications for an account, these operations affect every key visible to your account at that POP, not only those written by the calling application. +The JavaScript SDK provides a `getOrSet` operation: if the key exists, its value is returned immediately; if not, a provided callback computes the value, stores it, and returns it. This is useful for read-through caching where computation is expensive. -## When to use Cache vs Edge Storage +`purge` removes all cache keys visible to the application; `purgePrefix` removes all keys whose names begin with a given string. Both return the number of keys deleted. Because Cache is shared across all applications for an account at a POP, these operations affect every key visible to your account at that POP, not only those written by the calling application. + +## Cache vs Edge Storage Cache and [Edge Storage](/fastedge/kv-stores/how-it-works) solve different problems. Use this table to decide which one fits your workload. -| | Cache | Edge Storage (KV) | +| | Cache | Edge Storage | | ------------------- | ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------- | | Scope | Single POP | Globally replicated to all POPs | | Consistency | Strong (within a POP) | Eventual (1–2 seconds globally) | @@ -30,28 +34,122 @@ Cache and [Edge Storage](/fastedge/kv-stores/how-it-works) solve different probl | Provisioning | None — available at runtime on paid plans | Created in the Customer Portal and linked to your application | | Writes from the API | No (runtime only) | Yes | | Atomic counters | Yes (`incr`; `decr` JS only) | No | -| Typical workloads | Rate limits, response memoization, idempotency keys, per-request deduplication | Configuration, feature flags, lookup tables, blocklists, sorted sets, Bloom filters | +| Typical workloads | Rate limits, response memoization, idempotency keys, per-request deduplication | Configuration, feature flags, lookup tables, blocklists, sorted sets, Bloom Filters | -A common pattern is to use both together: store the source of truth in Edge Storage and use Cache to memoize derived results or to enforce per-POP rate limits. +A common pattern is to use both together: store the source of truth in Edge Storage and use Cache to memoize derived results or enforce per-POP rate limits. -## API surface +## Available operations -The Cache API is exposed to FastEdge applications via the SDK. The available operations are: +| Operation | Description | +| --------- | ----------- | +| `get` | Fetch a cached value by key. Returns `None`/`null` on a miss. | +| `set` | Write or overwrite a value with an optional TTL. | +| `delete` | Remove a key from the cache. | +| `exists` | Check whether a key is present without fetching its value. | +| `incr` | Atomically increment (or decrement) an integer counter. | +| `decr` | Decrement a counter. JavaScript SDK only. | +| `expire` | Set or update the TTL of an existing key. Returns `false` if the key no longer exists. | +| `getOrSet` | Fetch a value, or compute and store it if missing. JavaScript SDK only. | +| `purge` | Delete all cache keys visible to the application at the current POP. | +| `purgePrefix` | Delete all keys whose names begin with a given prefix. | -- **Reading and writing**: `get`, `set`, `delete`, `exists` -- **Atomic operations and TTL**: `incr`, `decr` (JS only), `expire` -- **Get-or-populate**: `getOrSet` (JS only) for read-through caching with coalesced population -- **Bulk deletion**: `purge` (delete all keys), `purgePrefix` (delete all keys matching a prefix) +In the JavaScript SDK, expiration is specified per write as `{ ttl: seconds }`, `{ ttlMs: milliseconds }`, or `{ expiresAt: unixTimestamp }`. In the Rust SDK, TTL is always in milliseconds (`Option`). Entries with no expiration remain until evicted. -Expiration is specified per write as a TTL (`ttl`, `ttlMs`) or an absolute deadline (`expiresAt`). Entries with no expiration remain until evicted. +## SDK examples -## Accessing Cache in applications +The following examples cover the most common Cache patterns. For the full API reference, see the [JavaScript SDK](https://g-core.github.io/FastEdge-sdk-js/reference/fastedge/cache/) and [Rust SDK](https://docs.rs/fastedge/latest/fastedge/cache/) documentation. -For more information regarding Cache usage in applications, see the [JavaScript SDK](https://g-core.github.io/FastEdge-sdk-js/reference/fastedge/cache/) and the [Rust SDK](https://docs.rs/fastedge/latest/fastedge/cache/). +### Read and write a value - -**Info** + + -Cache does not need to be created or linked to your application. It is available to every FastEdge application on a paid plan at runtime by importing the cache module from the SDK. +```javascript +import { Cache } from 'fastedge::cache'; - +await Cache.set('config:feature-x', 'enabled', { ttl: 300 }); // 5-minute TTL + +const value = await Cache.get('config:feature-x'); +if (value === null) { + // cache miss — compute and store +} + +await Cache.delete('config:feature-x'); +``` + + + + +```rust +use fastedge::cache; + +cache::set("config:feature-x", b"enabled".to_vec(), Some(300_000))?; // 5 min in ms + +match cache::get("config:feature-x")? { + Some(data) => { + let value = String::from_utf8_lossy(&data); + // use value + } + None => { + // cache miss — compute and store + } +} + +cache::delete("config:feature-x")?; +``` + + + + +### Rate limiting with an atomic counter + + + + +```javascript +import { Cache } from 'fastedge::cache'; + +const ip = event.client.address ?? 'unknown'; +const key = `rl:${ip}`; + +const count = await Cache.incr(key); +if (count === 1) { + // First request in the window — set a 60-second TTL + await Cache.expire(key, { ttl: 60 }); +} + +if (count > 100) { + return new Response('Too Many Requests', { status: 429 }); +} +``` + + + + +```rust +use fastedge::cache; + +let ip = request.headers() + .get("x-real-ip") + .and_then(|v| v.to_str().ok()) + .unwrap_or("unknown"); + +let key = format!("rl:{ip}"); + +// Increment by 1; create the counter at 0 if it does not exist +let count = cache::incr(&key, 1)?; + +if count == 1 { + // First request in the window — set a 60-second TTL (60 000 ms) + cache::expire(&key, 60_000)?; +} + +if count > 100 { + return Ok(Response::builder() + .status(429) + .body(Body::from("Too Many Requests"))?); +} +``` + + + diff --git a/fastedge/create-apps.mdx b/fastedge/create-apps.mdx deleted file mode 100644 index 7392b63b4..000000000 --- a/fastedge/create-apps.mdx +++ /dev/null @@ -1,11 +0,0 @@ ---- -title: Create FastEdge apps -sidebarTitle: Create apps -ai-navigation: Create FastEdge HTTP and CDN applications using Rust SDK, JavaScript SDK, or Proxy-Wasm spec to run serverless code on Gcore's CDN network with custom URLs and request/response processing. ---- - -FastEdge allows you to run applications in a serverless environment on Gcore's scalable CDN network. You can create the following types of FastEdge apps: - - * **HTTP applications** : manage apps that have their own URL and are built using [FastEdge Rust SDK](https://github.com/G-Core/FastEdge-sdk-rust) or [FastEdge JavaScript SDK](https://github.com/G-Core/FastEdge-sdk-js). - - * **CDN applications** : manage apps that extend the functionality of Gcore CDN and use [Proxy-Wasm](https://github.com/proxy-wasm/spec) spec. \ No newline at end of file diff --git a/fastedge/create-manage-templates.mdx b/fastedge/create-manage-templates.mdx index 957fcd895..d6d161e00 100644 --- a/fastedge/create-manage-templates.mdx +++ b/fastedge/create-manage-templates.mdx @@ -1,56 +1,63 @@ --- title: Create and manage templates sidebarTitle: Create and manage templates -ai-navigation: Create FastEdge templates with custom binary files, mandatory parameters, and Secret environment variables for HTTP and CDN applications via Customer Portal. +ai-navigation: Create, edit, delete, and update FastEdge templates for HTTP and CDN applications via the Customer Portal or REST API — including binary upload, mandatory parameters, secret environment variables, and creating apps from templates. --- -Templates include predefined configurations for FastEdge apps. Using templates eliminates the need to manually configure each aspect of an application, which speeds up the configuration process and ensures consistency across deployments. +import { MethodSwitch, MethodSection } from "/snippets/method-switch.jsx"; + + + + +A template packages a WebAssembly binary together with a predefined configuration — environment variables, secrets, response headers, and instructions — so the same application can be deployed repeatedly without reconfiguring it from scratch. Templates can be created from a new binary or saved from an existing application. ## Create a template -Both CDN and HTTP applications have the same template configuration process. +The configuration process is identical for HTTP and CDN applications. - To add a template to the Customer Portal: - - 1\. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge** and choose the relevant page: **HTTP Applications** or **CDN Applications**. + 1\. In the [Gcore Customer Portal](https://portal.gcore.com), navigate to **FastEdge** and open **HTTP Applications** or **CDN Applications**. - 2\. Open the **Templates** page and click **Create template**. + 2\. Select **Templates** and click **Create template**. ![Create template button](/images/docs/fastedge/create-manage-templates/create-template-button.png) - 3\. Add your custom binary file. Once the upload is finished, the file will be automatically assigned to the template. + 3\. Upload a `.wasm` binary. Click the upload area or drag and drop the file. Once the upload completes, click **Save binary** — the rest of the form fields appear after the binary is saved. ![Add raw binary dialog](/images/docs/fastedge/create-manage-templates/create-template-upload-binary.png) - 4\. Give your template a name. Use a clear and descriptive name to ensure the template is easy to identify. + 4\. Enter the template metadata: - 5\. (Optional) Add a description to provide extra information about the template. + - **Name** — required. + - **Description** — optional, shown in the template list. + - **Usage instructions** — optional, displayed when deploying from this template. Include any required variables or configuration notes. - 6\. (Optional) Add instructions for using the template. Include any critical information that's important to know when creating an app, such as required variables, headers, and any configuration tips. + 5\. Define template parameters: - 7\. Specify any parameters. To add a required parameter, select the **Mandatory parameter** checkbox. If you need to add encrypted environment variables to applications created from this template, add a new parameter with the type **Secret**. + - Leave the **Mandatory parameter** checkbox unchecked for optional parameters. + - Select **Mandatory parameter** to require a value at deployment time. + - Set the parameter type to **Secret** to link the value from Secrets Manager — the deploying user will need to supply a secret rather than a plain value. ![Secret parameter marked as required](/images/docs/fastedge/create-manage-templates/add-secret-parameter.png) - When creating an application based on this template, this parameter will appear as a "secret" that you can assign from the Secret Manager. Check detailed instructions on how to add [environment variables](/fastedge/manage-apps#environment-variables) and [secrets](/fastedge/manage-apps#secrets) to an application. - ![Example of a secret parameter in an app](/images/docs/fastedge/create-manage-templates/example-variable-encrypt.png) - 8\. Click **Save template**. + 6\. Click **Save template**. + + The template is now available in the account. - The template was successfully added. You can use this or any template shared by your admin to create FastEdge applications. To share the template with other users in your account, contact the admin for assistance. + + Templates are account-scoped. To make a template visible to other users in the account, contact the account admin. + - You can convert an existing application into a template for future reuse. The template will be created using the binary of the original application, and it will contain any associated environment variables. + Converting an existing application creates a template from its binary. The application name becomes the template name, and environment variable names are carried over as parameter definitions — their values are not included. - To add a template from an application: + 1\. In the Customer Portal, navigate to **FastEdge** and open **HTTP Applications** or **CDN Applications**. - 1\. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge** and choose the relevant page: **HTTP Applications** or **CDN Applications**. - - 2\. On the **Applications** page, click the three-dot icon next to the application you want to configure. + 2\. On the **Applications** page, click the three-dot icon next to the application. 3\. Select **Manage**. @@ -58,101 +65,300 @@ Both CDN and HTTP applications have the same template configuration process. ![Create template from app menu](/images/docs/fastedge/create-manage-templates/create-template-from-app.png) - 5\. Review the current configuration and, if necessary, update the template's name and description. + 5\. Review the configuration. Update the name and description if needed. - 6\. Click **Save template** to apply the changes. + 6\. Click **Save template**. ## Edit a template -To adjust the template configuration or add new settings: - -1\. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge** and choose the relevant page: **HTTP Applications** or **CDN Applications**. +1. In the Customer Portal, navigate to **FastEdge** and open **HTTP Applications** or **CDN Applications**. -2\. On the **Templates** page, click the three-dot icon next to the template that you want to edit. +2. Select **Templates** and click the three-dot icon next to the template. -3\. Click **Edit template**. +3. Click **Edit template**. - - ![Edit template menu - item](/images/docs/fastedge/create-manage-templates/edit-template-menu.png) - +![Edit template menu item](/images/docs/fastedge/create-manage-templates/edit-template-menu.png) -4\. Update the configuration as you see fit, and then click **Save template** to apply the changes. +4. Update the configuration and click **Save template**. - - ![Edit template - form](/images/docs/fastedge/create-manage-templates/edit-template-form.png) - - -The template has been updated. +![Edit template form](/images/docs/fastedge/create-manage-templates/edit-template-form.png) ## Delete a template -**Warning** +Deleted templates cannot be restored. + -Deleted templates can't be restored. +1. In the Customer Portal, navigate to **FastEdge** and open **HTTP Applications** or **CDN Applications**. - +2. Select **Templates** and click the three-dot icon next to the template. -1\. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge** and choose the relevant page: **HTTP Applications** or **CDN Applications**. +3. Click **Delete template**. -2\. On the **Templates** page, click the three-dot icon next to the template that you want to remove. +![Delete template menu item](/images/docs/fastedge/create-manage-templates/delete-template.png) -3\. Click **Delete template**. +## Update template binary - - ![Delete - template](/images/docs/fastedge/create-manage-templates/delete-template.png) - +Use this option to replace the WebAssembly binary without changing the template's name, description, or parameters. -You've permanently removed the template from the Customer Portal. +1. In the Customer Portal, navigate to **FastEdge** and open **HTTP Applications** or **CDN Applications**. -## Update template binary +2. Select **Templates** and click the three-dot icon next to the template. -If you want to update the application binary to a newer version or add substantial changes to the template configuration, you can replace the existing WebAssembly (.wasm) file with a new one. +3. Click **Update template binary**. -To update the binary file: +![Update template binary menu item](/images/docs/fastedge/create-manage-templates/update-template-binary.png) -1\. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge** and choose the relevant page: **HTTP Applications** or **CDN Applications**. +4. Upload the new `.wasm` file and click **Save binary**. -2\. On the **Templates** page, click the three-dot icon next to the template that you want to edit. +![Upload template binary dialog](/images/docs/fastedge/create-manage-templates/create-template-upload-binary.png) -3\. Click **Update template binary**. +5. Review the configuration and click **Save template**. - - ![Update template - binary](/images/docs/fastedge/create-manage-templates/update-template-binary.png) - +![Edit template binary form](/images/docs/fastedge/create-manage-templates/edit-template-binary.png) -4\. Add the new .wasm file from your local file system. Once the upload is finished, the file will be automatically added to the Customer Portal. +## Create an app from a template - - ![Upload template binary - dialog](/images/docs/fastedge/create-manage-templates/create-template-upload-binary.png) - +1. In the Customer Portal, navigate to **FastEdge** and open **HTTP Applications** or **CDN Applications**. -5\. Verify the current configuration and click **Save template** to apply the updates. +2. Select **Templates**, then click the three-dot icon next to the template and choose **Create app from template**. - - ![Edit template binary - form](/images/docs/fastedge/create-manage-templates/edit-template-binary.png) - +3. Complete the application configuration: -## Create an app from a template +- [HTTP application from a template](/fastedge/getting-started/create-fastedge-apps#deploy-an-app-from-a-template) +- [CDN application from a template](/fastedge/getting-started/integrate-cdn-with-fastedge#deploy-from-the-template) + +After deployment, the application inherits the template's binary and predefined configuration. Any mandatory parameters defined in the template must be supplied during deployment. + + + + + +A template packages a WebAssembly binary together with a predefined configuration — environment variables, secrets, response headers, and parameters — and can be deployed as an application any number of times without manual reconfiguration. -You can deploy a FastEdge application directly from the Templates page: +

All requests authenticate with an [API token](/account-settings/api-tokens). Set it as an environment variable before running the examples:

-1\. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge** and choose the relevant page: **HTTP Applications** or **CDN Applications**. +```bash +export GCORE_API_KEY="{YOUR_API_KEY}" +``` -2\. On the **Templates** page, find the template you want to use to create an application. +## Create a template + +Creating a template requires two steps: upload a `.wasm` binary, then create the template referencing that binary. + +### Upload a binary + +Send the raw `.wasm` file as an `application/octet-stream` body: + +```bash +curl -X POST https://api.gcore.com/fastedge/v1/binaries/raw \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/octet-stream" \ + --data-binary @my-app.wasm +``` + +The response contains the binary ID: + +```json +{ + "id": 4748, + "api_type": "wasi-http", + "status": 1 +} +``` + +The `api_type` is determined by the binary and cannot be set manually. Use the returned `id` as the `binary_id` in the next step. + +### Create the template + +```bash +curl -X POST https://api.gcore.com/fastedge/v1/template \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "My template", + "short_descr": "Short description shown in the template list", + "long_descr": "Full usage instructions shown at deployment time.", + "binary_id": BINARY_ID, + "owned": true, + "params": [ + { + "name": "BASE_URL", + "data_type": "string", + "descr": "Base URL for the application", + "mandatory": true + } + ] + }' +``` + +The response contains the created template: + +```json +{ + "id": 174, + "name": "My template", + "api_type": "wasi-http", + "short_descr": "Short description shown in the template list", + "long_descr": "Full usage instructions shown at deployment time.", + "owned": true +} +``` + +Template names may only contain letters, digits, spaces, underscores, and hyphens. + + +The `owned` field controls account visibility, not ownership. When set to `true`, the template is visible to all users in the account. When set to `false`, it is private to the token owner. + + +## List templates + +```bash +curl https://api.gcore.com/fastedge/v1/template \ + -H "Authorization: APIKey $GCORE_API_KEY" +``` + +To filter by application type, add the `api_type` query parameter (`wasi-http` for HTTP applications or `proxy-wasm` for CDN applications): + +```bash +curl "https://api.gcore.com/fastedge/v1/template?api_type=wasi-http&only_mine=true" \ + -H "Authorization: APIKey $GCORE_API_KEY" +``` + +The response field is `templates`: + +```json +{ + "count": 2, + "templates": [ + { + "id": 174, + "name": "My template", + "api_type": "wasi-http" + } + ] +} +``` + +## Get template details + +```bash +curl https://api.gcore.com/fastedge/v1/template/TEMPLATE_ID \ + -H "Authorization: APIKey $GCORE_API_KEY" +``` + +Response: + +```json +{ + "id": 174, + "name": "My template", + "api_type": "wasi-http", + "binary_id": 4748, + "short_descr": "Short description", + "long_descr": "Full usage instructions.", + "owned": true, + "params": [ + { + "name": "BASE_URL", + "data_type": "string", + "descr": "Base URL for the application", + "mandatory": true + } + ] +} +``` + +## Edit a template + + +`PUT` replaces the entire template definition. Any fields omitted from the request body — including `params` — are cleared. Always include the full configuration. + + +```bash +curl -X PUT https://api.gcore.com/fastedge/v1/template/TEMPLATE_ID \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "My template", + "short_descr": "Updated description", + "long_descr": "Updated usage instructions.", + "binary_id": BINARY_ID, + "owned": true, + "params": [ + { + "name": "BASE_URL", + "data_type": "string", + "descr": "Base URL for the application", + "mandatory": true + } + ] + }' +``` + +## Update template binary + +To replace the binary while keeping the name, description, and parameters, upload a new binary first, then update the template with the new `binary_id`. + +Upload the new binary: + +```bash +curl -X POST https://api.gcore.com/fastedge/v1/binaries/raw \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/octet-stream" \ + --data-binary @my-app-v2.wasm +``` + +Then update the template with the new binary ID: + +```bash +curl -X PUT https://api.gcore.com/fastedge/v1/template/TEMPLATE_ID \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "My template", + "short_descr": "Short description", + "long_descr": "Usage instructions.", + "binary_id": NEW_BINARY_ID, + "owned": true, + "params": [] + }' +``` + +## Delete a template + +```bash +curl -X DELETE https://api.gcore.com/fastedge/v1/template/TEMPLATE_ID \ + -H "Authorization: APIKey $GCORE_API_KEY" +``` -3\. Click the three-dot icon next to open template settings and select **Create app from template**. +A successful response returns HTTP 200 with an empty body. -4\. Proceed with the application configuration as described in the relevant guide: + +Deleted templates cannot be restored. Applications previously deployed from the template are not affected. + + +## Create an app from a template -- [Create an HTTP app from a template](/fastedge/getting-started/create-fastedge-apps#deploy-an-app-from-a-template) -- [Create a CDN app from a template](/fastedge/getting-started/integrate-cdn-with-fastedge#deploy-from-the-template) +Pass the template ID in the `template` field of the application creation request. Provide values for any mandatory parameters in `env`: + +```bash +curl -X POST https://api.gcore.com/fastedge/v1/apps \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "my-app", + "template": TEMPLATE_ID, + "env": { + "BASE_URL": "https://example.com" + } + }' +``` + +The application inherits the template's binary and configuration. The response includes the new application's `id` and `url`. + +
+
diff --git a/fastedge/fastedge-cli.mdx b/fastedge/fastedge-cli.mdx index 39f59949b..d46c1336f 100644 --- a/fastedge/fastedge-cli.mdx +++ b/fastedge/fastedge-cli.mdx @@ -1,94 +1,113 @@ --- title: FastEdge CLI sidebarTitle: FastEdge CLI -ai-navigation: Install FastEdge CLI from the FastEdge-lib repository, build the Rust-based tool, and execute local HTTP applications with commands supporting environment variables, geo headers, and request/response inspection. +ai-navigation: Install fastedge-run to test FastEdge Wasm applications locally before deploying. Available as a pre-built binary for macOS, Linux, and Windows, or bundled with the FastEdge VS Code extension. Supports HTTP server mode, environment variables, and geo header simulation. --- -Run and test your FastEdge HTTP applications locally with the Gcore [FastEdge CLI tool](https://github.com/G-Core/FastEdge-lib). The following instructions will help you install, build, and execute some basic commands with FastEdge CLI. +During FastEdge application development, deploying to the edge on every change is slow. `fastedge-run` eliminates that step: it runs the compiled Wasm binary locally and serves it over HTTP, so the application can be tested from the terminal without a new deployment. - -**Tip** + +The CLI is also bundled with the [FastEdge VS Code extension](https://github.com/G-Core/FastEdge-vscode). If you use VS Code, no separate installation is needed. + -We are actively developing [FastEdge CLI](https://github.com/G-Core/FastEdge-lib) and recommend regularly checking the FastEdge-lib repository for updates and new versions. - +## Install -## Install and set up FastEdge CLI +### Download a pre-built binary -1\. Clone the [FastEdge-lib](https://github.com/G-Core/FastEdge-lib) repository. +Pre-built binaries are available for all major platforms on the [FastEdge-lib releases page](https://github.com/G-Core/FastEdge-lib/releases). -2\. Install Rust by running the following command: +| Platform | File | +| -------- | ---- | +| macOS (Apple Silicon) | `fastedge-run-{version}-aarch64-apple-darwin.tar.gz` | +| Linux (x86\_64) | `fastedge-run-{version}-x86_64-unknown-linux-gnu.tar.gz` | +| Windows (x86\_64) | `fastedge-run-{version}-x86_64-pc-windows-msvc.zip` | -`curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source "$HOME/.cargo/env"` +Download and extract the archive, then move the `fastedge-run` binary to a directory on your `PATH`. -3\. In the directory where you cloned the repository, run the following command to initialize and update all submodules: `git submodule update --init --recursive -f` +### Build from source -4\. Build the CLI tool and all required dependencies: `cargo build –release` +If no pre-built binary is available for your platform, build from source: -5\. Compile and run the binary with the `help` flag to view the full list of available CLI commands and parameters: `cargo run --bin cli -- --help` +1. Install Rust: -## Run FastEdge CLI +```bash +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +source "$HOME/.cargo/env" +``` + +2. Clone the repository and initialize submodules: + +```bash +git clone https://github.com/G-Core/FastEdge-lib +cd FastEdge-lib +git submodule update --init --recursive -f +``` -To run the compiled CLI tool, use the following command: +3. Build the CLI: -```sh -./target/release/fastedge-run [command] +```bash +cargo build --release ``` -For example, if you want to open help and view the list of supported commands, run: `./target/release/fastedge-run http --help`. +The binary is at `./target/release/fastedge-run`. -## Example commands +## Run a Wasm application -This section provides some basic examples of how to work with FastEdge CLI. The sample commands use a test application from the [FastEdge-examples](https://github.com/G-Core/FastEdge-examples) repository. +Start a local HTTP server that executes your compiled Wasm binary: -### Run a FastEdge application and print all its headers +```bash +fastedge-run http -w ./app.wasm --port 8080 +``` -Execute the following command: +Then send requests to test the application: -```sh -./target/release/fastedge-run http –w [path-to-your-application] –-port [port number] +```bash +curl http://localhost:8080 ``` -For example: `./target/release/fastedge-run http -w ../FastEdge-examples/rust/target/wasm32-wasip1/release/print.wasm –-port 8080` +## Pass environment variables -To view the list of all printed headers, run `curl http://localhost:8080` +Set environment variables the same way they would be configured in the Customer Portal: -### Run a FastEdge application with environment variables +```bash +fastedge-run http -w ./app.wasm --env BASE=https://example.com --port 8080 +``` -Execute the following command: +Multiple variables can be passed by repeating `--env`: -```sh -./target/release/fastedge-run http –w [path-to-your-application] –-env [variables] --port [port number] +```bash +fastedge-run http -w ./app.wasm --env KEY1=value1 --env KEY2=value2 --port 8080 ``` -For example, to set the BASE variable to the URL of the repository's README: +## Simulate geo headers -`./target/release/fastedge-run http -w ../FastEdge-examples/rust/target/wasm32-wasip1/release/markdown.wasm env BASE=https://raw.githubusercontent.com/G-Core/FastEdge-lib/main --port 8080` +### Inject sample geo data -After executing the command, you can run the FastEdge application, which will output the contents of the README: `http://localhost:8080/README.md` +Use `--geo` to add a fixed set of sample geo headers to every incoming request: + +```bash +fastedge-run http -w ./app.wasm --geo --port 8080 +``` + +The following headers are added to the request: + +``` +pop-continent: eu +pop-country-code: au +pop-country-name: luxembourg +pop-city: luxembourg +pop-reg: lu +pop-lat: 49.6113 +pop-long: 6.1294 +server_name: test.localhost +``` -### Run an application with sample geo headers +### Inject specific headers -FastEdge CLI can add sample geo headers to your application without using a real IP address: +Use `--headers` to set individual headers with exact values. This is useful when testing logic that depends on a specific country code or region: -```sh -./target/release/fastedge-run http -w [path-to-your-application] –geo –port [port number] +```bash +fastedge-run http -w ./app.wasm --headers pop-country-code=DE --headers pop-country-name=Germany --port 8080 ``` -For example: `./target/release/fastedge-run http -w ../FastEdge-examples/rust/target/wasm32-wasip1/release/print.wasm –-geo --port 8081` - -To view the list of sample geo headers, run `curl http://localhost:8081`. You should see an output similar to the following: - -```yaml -Headers: - host: localhost:8081 - user-agent: curl/8.6.0 - accept: */* - pop-country-name: luxembourg - pop-city: luxembourg - pop-country-code: au - server_name: test.localhost - pop-continent: eu - pop-lat: 49.6113 - pop-long: 6.1294 - pop-reg: lu% -``` \ No newline at end of file +Use `fastedge-run http --help` to see all available options. diff --git a/fastedge/geolocation-redirect.mdx b/fastedge/geolocation-redirect.mdx new file mode 100644 index 000000000..0719843d0 --- /dev/null +++ b/fastedge/geolocation-redirect.mdx @@ -0,0 +1,66 @@ +--- +title: Redirect visitors by location +sidebarTitle: Geolocation redirect +ai-navigation: Deploy the FastEdge geolocation redirect template to route visitors to region-specific URLs based on their country via the Customer Portal. +--- + +The geolocation redirect is a built-in FastEdge application that detects each visitor's country from Gcore's Geo-IP data and issues an HTTP 302 redirect to the corresponding URL. Redirect rules are configured through environment variables. No custom code or binary compilation is required. + +A common use case is routing international visitors to regional landing pages, language-specific subdomains, or data-residency-compliant endpoints without client-side JavaScript or origin-side logic. + +## Create the application + +1. In the [Gcore Customer Portal](https://portal.gcore.com), navigate to **FastEdge** > **HTTP Applications** > **Applications** and click **Create new application**. + +2. Scroll to **Create from a template** and click **Geolocation-based redirect**. + + ![Create an application page showing Upload binary and Create from a template sections with Geolocation-based redirect and Markdown renderer cards](/images/docs/fastedge/geolocation-redirect/create-from-template-overview.png) + +3. Enter a **Name** for the application. + +4. Set the **DEFAULT** variable in the **Template environment variables** section. This is the fallback redirect URL for visitors whose country does not match any rule — every deployment requires it. + + ![Geolocation-based redirect form with DEFAULT field and Response headers section](/images/docs/fastedge/geolocation-redirect/geolocation-redirect-form.png) + +5. Add country rules in the **Environment variables** section. Each rule is one variable: country code as the key, redirect URL as the value. Visitors from countries not listed fall through to `DEFAULT`. For example: + + | Variable | Value | + |----------|-------| + | `DEFAULT` | `https://example.com/en` | + | `DE` | `https://example.com/de` | + | `FR` | `https://example.com/fr` | + | `JP` | `https://example.com/jp` | + +6. (Optional) Configure response headers, secrets, or [Edge Storage](/fastedge/kv-stores/manage-kv-store) as needed. + +7. Click **Save and deploy**. + +The application details page opens with the deployment URL. + +## Test the application + +Send a request to the app URL and inspect the redirect response: + +```sh +curl -i https://-.fastedge.app/ +``` + +When the request originates from a country with a matching rule, the response is: + +``` +HTTP/1.1 302 Found +location: https://example.com/de +``` + +When no country rule matches, the response redirects to `DEFAULT`: + +``` +HTTP/1.1 302 Found +location: https://example.com/en +``` + +The redirect applies to all URL paths — `/pricing`, `/contact`, and `/` all redirect using the same country logic. To restrict redirects to a specific path, use a [custom binary](/fastedge/getting-started/get-started-http) with a path check instead of this template. + + +Country codes, redirect targets, and `DEFAULT` can all be updated from the application management page without rebuilding or redeploying the application. + diff --git a/fastedge/getting-started.mdx b/fastedge/getting-started.mdx index 7568e1a59..9005e747c 100644 --- a/fastedge/getting-started.mdx +++ b/fastedge/getting-started.mdx @@ -1,54 +1,61 @@ --- title: FastEdge overview -sidebarTitle: Getting started -ai-navigation: Deploy WebAssembly applications on Gcore's global edge network using FastEdge for serverless execution with HTTP request/response modification, A/B testing, personalization, image conversion, and custom DNS resolving without infrastructure maintenance. +sidebarTitle: Overview +ai-navigation: Overview of FastEdge serverless WebAssembly execution on Gcore edge network - HTTP Applications, CDN Applications, use cases including A/B testing, personalization, authentication, and image manipulation. --- -FastEdge is a Gcore product for serverless execution of apps at the edge. Apps compiled to WebAssembly run on Gcore's global edge network, with no environment configuration or infrastructure maintenance required. Common uses include request modification, frontend serving, image conversion, and custom DNS resolving. +FastEdge runs WebAssembly applications on Gcore's global edge network. Apps execute at the edge node closest to the request — no infrastructure to configure or maintain. Common use cases include A/B testing, personalization, authentication, and image processing. -## Processing model +## Application types -FastEdge offers two processing modes: +FastEdge supports two application types: HTTP and CDN. The application type determines how the application integrates with FastEdge and which setup guide to follow. -* Without HTTP request modification. Select functions run at the edge without modifying HTTP requests. This improves speed and scalability because some requests are handled by edge network servers rather than reaching the application's web server. -* With HTTP request and response modification. A FastEdge node modifies HTTP requests according to the functions' logic before forwarding them to the application's web server. The edge node then intercepts the web server's HTTP response, modifies it according to the functions' logic, and sends it to the end user. +**Modern HTTP applications** receive and respond to HTTP requests directly. They implement the [WASI P2](https://wasi.dev/releases/wasi-p2) `wasi:http/proxy` interface — the current recommended standard for WebAssembly HTTP applications. Supported in Rust (via the `wstd` crate) and JavaScript. Use this type for new edge services: APIs, redirects, authentication proxies, and similar workloads. -For both modes, the general flow is: +**Legacy HTTP applications** also handle HTTP requests directly, but use Gcore's own `fastedge` crate rather than the WASI standard. They target [WASI P1](https://wasi.dev/releases/wasi-p1), the original WebAssembly system interface. Use it when maintaining existing applications built on the `fastedge` crate. -1. Add application code to FastEdge. -2. Gcore deploys the code on edge servers worldwide, and all traffic is automatically routed and load-balanced across edge nodes. -3. When a request arrives, the runtime executes the code and returns an HTTP response. -4. FastEdge nodes act as origins to terminate HTTP requests, or as proxies to modify them along the way. +**CDN applications** run inside a CDN resource's request pipeline. They implement the [Proxy-Wasm](https://github.com/proxy-wasm/spec) specification — an open standard for WebAssembly-based proxy extensions — and can intercept traffic at four stages: on request headers, on request body, on response headers, and on response body. Supported in Rust and AssemblyScript. Use this type when extending an existing CDN-served site with edge logic. -## Key benefits +To get started, choose the setup guide that matches the application type and language: + +| App type | Language | Setup guide | +|----------|----------|-------------| +| Modern HTTP | Rust | [Rust (Modern HTTP)](/fastedge/getting-started/setup-rust-modern) | +| Modern HTTP | JavaScript | [JavaScript](/fastedge/getting-started/setup-javascript) | +| Legacy HTTP | Rust | [Rust (Legacy HTTP)](/fastedge/getting-started/setup-rust-legacy) | +| CDN | Rust | [Rust (CDN / Proxy-Wasm)](/fastedge/getting-started/setup-rust-cdn) | -FastEdge provides the following performance and development advantages. +Both application types share the same deployment workflow: -* Low latency everywhere. FastEdge runs over Gcore's global edge network, so services are closer to end users regardless of location, resulting in low latency. -* Quick development. FastEdge supports building highly responsive and personalized apps that rely heavily on dynamically generated content. -* Built for innovation. FastEdge handles all backend orchestration, freeing teams to focus on coding and creativity. -* Enhanced security. Each edge app runs within the WebAssembly sandbox, isolating it from other edge apps. +1. Compile the application to WebAssembly and [upload the binary](/fastedge/getting-started/create-fastedge-apps) to FastEdge. +2. Gcore deploys it across edge nodes worldwide. Traffic is automatically routed and load-balanced. +3. When a request arrives, the runtime executes the application and returns the result to the client. + +## Key benefits -## FastEdge use cases +- **Run code close to users.** FastEdge executes on the edge node closest to each request, reducing round-trip latency without relocating the origin. +- **Deploy without managing servers.** Gcore handles deployment, scaling, and routing across the global network. The application binary is the only artifact to maintain. +- **Isolated execution per application.** Each application runs in a WebAssembly sandbox, isolated from other applications on the same node. +- **Write in Rust or JavaScript.** Both languages have first-class SDK support. Rust covers both HTTP and CDN application types; JavaScript supports HTTP applications. -FastEdge covers a wide range of serverless use cases at the edge. +## Use cases ### A/B testing -When testing a new application version with a limited audience, FastEdge's A/B testing feature controls what percentage of users receive the new version. Split logic can include additional parameters such as geolocation or a specific subnet. +Split traffic between application versions at the edge — by percentage, geolocation, subnet, or a combination. Teams test changes on a limited audience before a full rollout, with no changes to the origin required. ### Personalization -For global businesses, personalizing content by customer segment is essential. FastEdge applies logic based on geolocation, IP, or other HTTP request header data — serving customers in Frankfurt with German-language content and Euro pricing, and customers in California with English and US dollars. +Serve region-specific content based on geolocation, IP address, or request headers — different language, currency, or product catalog per market — without modifying the origin application. ### Authentication -For a paid-access educational service integrated with Gcore CDN, FastEdge handles JWT token validation at the edge. Subscribers receive a JWT token; the edge validates request parameters (IP, key, validity time) against a validation key before the request reaches the origin. The origin server then processes only validated requests, reducing its load. +Validate JWT tokens at the edge before a request reaches the origin. The origin processes only validated requests, reducing its load and eliminating a network round-trip for invalid ones. ### Image manipulation -For pay-per-load stock photography services, FastEdge functions handle image conversion at the edge, including bulk conversion to WebP, low-resolution resizing, and watermarking to prevent unauthorized use. +Convert images at the edge node closest to the request — bulk WebP conversion, low-resolution resizing, watermarking — rather than at a central origin, reducing bandwidth and processing load. -### Improved user experience +### URL rewriting and header control -When an application uses a CMS that generates non-human-readable URLs, FastEdge rewrites URLs to a user-friendly format in the response. Undesirable custom HTTP headers can also be removed from responses. +Rewrite non-human-readable CMS URLs to a user-friendly format in the response, and add or remove HTTP headers — without touching the origin application. diff --git a/fastedge/getting-started/build-a-rust-wasi-app.mdx b/fastedge/getting-started/build-a-rust-wasi-app.mdx deleted file mode 100644 index 5b30b9130..000000000 --- a/fastedge/getting-started/build-a-rust-wasi-app.mdx +++ /dev/null @@ -1,323 +0,0 @@ ---- -title: Build Rust WASI-HTTP apps -sidebarTitle: Rust WASI-HTTP apps -ai-navigation: Build FastEdge Rust applications using the WASI-HTTP interface - from a hello-world component that verifies the toolchain to an app that fetches and shapes data from an external API. ---- - -FastEdge runs applications as WebAssembly components — libraries that export a single entry-point function and execute on a global edge network without servers or containers. These components use [WASI-HTTP](https://github.com/WebAssembly/WASI) to receive requests and call external services, and `wstd` is the Rust library that implements it — the only dependency a FastEdge app in Rust needs. - -By the end of this guide: - -- A Rust component compiles to WebAssembly and deploys to FastEdge -- Incoming HTTP requests are handled and a response is returned -- A second component calls an external REST API from inside the handler, transforms the response, and returns shaped JSON - -[Rust and Cargo](https://rustup.rs) are required. On Windows, Rust dependencies require native compilation tools — install [Visual Studio Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022) with the **Desktop development with C++** workload. - -## Toolchain verification - -This component reads the request URL and echoes it back: minimal code, but enough to exercise the complete build-upload-deploy pipeline. - -### Project setup - -Rust builds libraries with `cargo new --lib`. Before that project can compile to a WebAssembly component, two things need to be in place: a compilation target that tells Rust which platform to target, and a Cargo configuration that changes the output format to something the WASI runtime can load. - -1. Add the `wasm32-wasip2` compilation target — without it, Cargo can't produce a WebAssembly component compatible with FastEdge. It's a one-time step: - - ```sh - rustup target add wasm32-wasip2 - ``` - -2. Create the library crate: - - ```sh - cargo new --lib hello-world - cd hello-world - ``` - -3. By default, `cargo new --lib` produces a Rust `rlib` — a format for linking into other Rust programs. FastEdge needs a `cdylib` instead: a C-compatible shared library that the WASI runtime can load as a component. Open `Cargo.toml` and replace its contents: - - ```toml - [package] - name = "hello_world" - version = "0.1.0" - edition = "2021" - - [lib] - crate-type = ["cdylib"] - - [dependencies] - wstd = "0.6" - anyhow = "1" - ``` - - The `[package]` and `[dependencies]` sections are standard Cargo. The only change from the default is `crate-type = ["cdylib"]` in `[lib]` — without it, the build succeeds but the output can't run as a WebAssembly component. - -### Handler - -FastEdge calls a single function for every HTTP request — the component's entry point. In `wstd`, this is an async function marked with `#[wstd::http_server]`: the attribute tells the runtime which function to call, the function receives a `Request`, and it must return a `Response` wrapped in `anyhow::Result`. - -`cargo new --lib` generates a default `src/lib.rs` with placeholder code — replace it with the actual handler: - -```rust -use wstd::http::body::Body; -use wstd::http::{Request, Response}; - -#[wstd::http_server] -async fn main(request: Request) -> anyhow::Result> { - let url = request.uri().to_string(); - - Ok(Response::builder() - .status(200) - .header("content-type", "text/plain;charset=UTF-8") - .body(Body::from(format!( - "Hello, you made a wasi request to {url}" - )))?) -} -``` - -### Build - -Compile the component to WebAssembly: - -```sh -cargo build --release --target wasm32-wasip2 -``` - -The first build downloads and compiles all dependencies, so expect it to take one to two minutes. Once it completes, Cargo writes the compiled component to `./target/wasm32-wasip2/release/hello_world.wasm`. - -### Deployment and testing - -FastEdge separates binaries from apps: a binary is a compiled WebAssembly file stored on the platform, and an app is a named endpoint that references a binary. Deploying requires two API calls — upload the binary first to get an ID, then create the app using that ID. - -Both calls authenticate with a permanent [API token](/account-settings/api-tokens), so set it before running the commands: - -```sh -export GCORE_API_KEY="{YOUR_API_KEY}" -``` - - -Do not commit API keys to source control. - - -Upload the binary: - -```sh -curl -sX POST 'https://api.gcore.com/fastedge/v1/binaries/raw' \ - -H "Authorization: APIKey $GCORE_API_KEY" \ - -H 'Content-Type: application/octet-stream' \ - --data-binary "@./target/wasm32-wasip2/release/hello_world.wasm" -``` - -```json -{"id": 4695, "api_type": "wasi-http", "status": 1} -``` - -Use the `id` from the upload response to create the app. The binary ID and app URL in the examples below will differ from the ones returned by the upload: - -```sh -export BINARY_ID=4695 - -curl -sX POST 'https://api.gcore.com/fastedge/v1/apps' \ - -H "Authorization: APIKey $GCORE_API_KEY" \ - -H 'Content-Type: application/json' \ - -d "{\"name\": \"my-hello-world\", \"binary\": $BINARY_ID, \"status\": 1}" -``` - -```json -{"name": "my-hello-world", "url": "https://my-hello-world-1000503.fastedge.app", "api_type": "wasi-http"} -``` - -The URL becomes active within a few seconds — send a request to confirm the handler is running: - -```sh -curl -i https://my-hello-world-1000503.fastedge.app/test-path -``` - -``` -HTTP/1.1 200 OK -content-type: text/plain;charset=UTF-8 - -Hello, you made a wasi request to http://my-hello-world-1000503.fastedge.app/test-path -``` - -The complete pipeline works. The next section adds outbound HTTP calls — the capability that turns a WASI component into a useful data-fetching layer. - -## Fetch data from an external API - -The first component demonstrates the basic request-response cycle, but it only operates on the incoming request. WASI-HTTP's key capability is that the handler can make outbound HTTP calls — reach out to any external service, transform the response, and return the result to the original caller. This component fetches a list of users from a public REST API and returns the first five as JSON. - - -The examples use `jsonplaceholder.typicode.com`, a free placeholder API, as a stand-in for any REST endpoint. It is suitable for development and testing only — do not use it in production. - - -### Project setup - -Create a separate project for this component: - -```sh -cargo new --lib outbound-fetch -cd outbound-fetch -``` - -The configuration is identical to the first component, with one addition: `serde_json` for parsing the upstream API response. Replace `Cargo.toml`: - -```toml -[package] -name = "outbound_fetch" -version = "0.1.0" -edition = "2021" - -[lib] -crate-type = ["cdylib"] - -[dependencies] -wstd = "0.6" -anyhow = "1" -serde_json = "1" -``` - -This example uses `serde_json::Value` — an untyped JSON tree — rather than defining structs. For slicing and reshaping an existing JSON response, this avoids deserializing into types that exist only to be re-serialized. - -### Handler - -The handler follows the same request-response pattern as the first example, but adds an outbound HTTP call and JSON transformation. Replace `src/lib.rs`: - -```rust -use anyhow::anyhow; -use wstd::http::body::Body; -use wstd::http::{Client, Request, Response}; -use serde_json::{json, Value}; - -#[wstd::http_server] -async fn main(_request: Request) -> anyhow::Result> { - let upstream_req = Request::get("http://jsonplaceholder.typicode.com/users") - .body(Body::empty()) - .map_err(|e| anyhow!("failed to build request: {e}"))?; - - let client = Client::new(); - let upstream_resp = client - .send(upstream_req) - .await - .map_err(|e| anyhow!("upstream request failed: {e}"))?; - - let (_, mut body) = upstream_resp.into_parts(); - let body_bytes = body.contents().await?; - - let users: Value = serde_json::from_slice(body_bytes)?; - let sliced = match users.as_array() { - Some(arr) => Value::Array(arr.iter().take(5).cloned().collect()), - None => Value::Array(vec![]), - }; - - let result = json!({ - "users": sliced, - "total": 5, - "skip": 0, - "limit": 30, - }); - - Ok(Response::builder() - .status(200) - .header("content-type", "application/json") - .body(Body::from(result.to_string()))?) -} -``` - -Three patterns here appear in most WASI-HTTP components and are worth understanding before adapting this code to a real endpoint. - -Components run in a WebAssembly sandbox with no access to native sockets. `Client::new()` creates a client that routes requests through the WASI outbound-http interface — the host runtime handles the actual network call. The `await` on `client.send()` is real async: the handler yields while the upstream request is in flight. - -The response body arrives as a stream. `upstream_resp.into_parts()` separates the response metadata from that stream, and `body.contents().await` reads it fully into memory as a byte slice before parsing. This is the right approach when the upstream response is small enough to buffer; for large responses that only need to be forwarded without transformation, the stream can be passed through directly without loading it into memory first. - -Every `?` in the handler propagates errors back through `anyhow::Result` — FastEdge converts any handler returning `Err` into a 500 response, with the error message written to application logs rather than the response body. This means errors stay server-side and never leak to the caller. - -### Build - -Compile the component using the same command as before: - -```sh -cargo build --release --target wasm32-wasip2 -``` - -Once it completes, Cargo writes the compiled component to `./target/wasm32-wasip2/release/outbound_fetch.wasm`. - -### Deployment and testing - -Upload and deploy using the same pattern as the first component: - -```sh -curl -sX POST 'https://api.gcore.com/fastedge/v1/binaries/raw' \ - -H "Authorization: APIKey $GCORE_API_KEY" \ - -H 'Content-Type: application/octet-stream' \ - --data-binary "@./target/wasm32-wasip2/release/outbound_fetch.wasm" -``` - -```json -{"id": 4696, "api_type": "wasi-http", "status": 1} -``` - -Save the returned `id` and use it to create the app: - -```sh -export BINARY_ID=4696 - -curl -sX POST 'https://api.gcore.com/fastedge/v1/apps' \ - -H "Authorization: APIKey $GCORE_API_KEY" \ - -H 'Content-Type: application/json' \ - -d "{\"name\": \"my-outbound-fetch\", \"binary\": $BINARY_ID, \"status\": 1}" -``` - -The URL from the create-app response becomes active within a few seconds: - -```sh -curl https://my-outbound-fetch-1000503.fastedge.app/ -``` - -The component fetches from the upstream API, takes the first five users from the response, and returns them as a shaped JSON payload: - -```json -{ - "limit": 30, - "skip": 0, - "total": 5, - "users": [ - { - "id": 1, - "name": "Leanne Graham", - "username": "Bret", - "email": "Sincere@april.biz", - "phone": "1-770-736-8031 x56442", - "website": "hildegard.org" - }, - { - "id": 2, - "name": "Ervin Howell", - "username": "Antonette", - "email": "Shanna@melissa.tv", - "phone": "010-692-6593 x09125", - "website": "anastasia.net" - } - ] -} -``` - -The outbound call happens on every request, from every edge node that handles traffic for this app — for data that changes infrequently, storing the upstream response in a [FastEdge KV store](/fastedge/kv-stores/manage-kv-store) eliminates that per-request latency after the first fetch. - -## Cleanup - -To delete an app, use its `id` from the create-app response: - -```sh -curl -sX DELETE "https://api.gcore.com/fastedge/v1/apps/{APP_ID}" \ - -H "Authorization: APIKey $GCORE_API_KEY" -``` - -Deleting the app does not remove the binary — to remove it as well: - -```sh -curl -sX DELETE "https://api.gcore.com/fastedge/v1/binaries/{BINARY_ID}" \ - -H "Authorization: APIKey $GCORE_API_KEY" -``` - -A binary referenced by an active application cannot be deleted — remove the app first. diff --git a/fastedge/getting-started/call-external-api-rust.mdx b/fastedge/getting-started/call-external-api-rust.mdx new file mode 100644 index 000000000..a9fe6499e --- /dev/null +++ b/fastedge/getting-started/call-external-api-rust.mdx @@ -0,0 +1,316 @@ +--- +title: Call an external API from a FastEdge app +sidebarTitle: Call an external API +ai-navigation: Build and deploy a FastEdge application in Modern Rust, Legacy Rust, or JavaScript that makes outbound HTTP requests, fetches data from a REST API, and returns shaped JSON via Customer Portal or REST API. +--- + +import { MethodSwitch, MethodSection } from "/snippets/method-switch.jsx"; + +FastEdge applications can make outbound HTTP calls from inside the handler — reach out to any external service, transform the response, and return the result to the caller. This guide builds an application that fetches a list of users from a public REST API and returns the first five as JSON. It assumes the [toolchain](/fastedge/getting-started) is already configured for the chosen language. + + +## Handler + +Create a new library crate or project, then write the handler for the chosen language. + + + + +Create a library crate and replace `Cargo.toml`: + +```sh +cargo new --lib outbound-fetch +cd outbound-fetch +``` + +```toml +[package] +name = "outbound_fetch" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +wstd = "0.6" +anyhow = "1" +serde_json = "1" +``` + +Replace `src/lib.rs`: + +```rust +use anyhow::anyhow; +use wstd::http::body::Body; +use wstd::http::{Client, Request, Response}; +use serde_json::{json, Value}; + +#[wstd::http_server] +async fn main(_request: Request) -> anyhow::Result> { + let upstream_req = Request::get("https://jsonplaceholder.typicode.com/users") + .body(Body::empty()) + .map_err(|e| anyhow!("failed to build request: {e}"))?; + + let client = Client::new(); + let upstream_resp = client + .send(upstream_req) + .await + .map_err(|e| anyhow!("upstream request failed: {e}"))?; + + let (_, mut body) = upstream_resp.into_parts(); + let body_bytes = body.contents().await?; + + let users: Value = serde_json::from_slice(body_bytes)?; + let sliced = match users.as_array() { + Some(arr) => Value::Array(arr.iter().take(5).cloned().collect()), + None => Value::Array(vec![]), + }; + let count = sliced.as_array().map(|a| a.len()).unwrap_or(0); + + Ok(Response::builder() + .status(200) + .header("content-type", "application/json") + .body(Body::from(json!({ "count": count, "users": sliced }).to_string()))?) +} +``` + +`Client::new()` routes requests through the WASI outbound-http interface — the host runtime handles the actual network call. The `await` on `client.send()` is real async: the handler yields while the upstream request is in flight. The response body arrives as a stream; `body.contents().await` reads it fully into memory before parsing. Every `?` propagates errors through `anyhow::Result` — FastEdge converts a handler returning `Err` into a 500 response, with the error message written to application logs. + + + + +Create a library crate and replace `Cargo.toml`: + +```sh +cargo new --lib outbound-fetch +cd outbound-fetch +``` + +```toml +[package] +name = "outbound_fetch" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +fastedge = "0.4" +anyhow = "1" +serde_json = "1" +``` + +Replace `src/lib.rs`: + +```rust +use fastedge::body::Body; +use fastedge::http::{Method, Request, Response, StatusCode}; +use serde_json::{json, Value}; + +#[fastedge::http] +fn main(_req: Request) -> anyhow::Result> { + let upstream_req = Request::builder() + .method(Method::GET) + .uri("https://jsonplaceholder.typicode.com/users") + .body(Body::empty())?; + + let upstream_resp = fastedge::send_request(upstream_req)?; + + let body = upstream_resp.into_body(); + let users: Value = serde_json::from_slice(&body)?; + let sliced = match users.as_array() { + Some(arr) => Value::Array(arr.iter().take(5).cloned().collect()), + None => Value::Array(vec![]), + }; + let count = sliced.as_array().map(|a| a.len()).unwrap_or(0); + + Ok(Response::builder() + .status(StatusCode::OK) + .header("content-type", "application/json") + .body(Body::from(json!({ "count": count, "users": sliced }).to_string()))?) +} +``` + +`fastedge::send_request()` is a synchronous blocking call — the handler waits until the full upstream response arrives. The response body is immediately available as a byte slice via `into_body()`, with no streaming step needed. Every `?` propagates errors through `anyhow::Result` — FastEdge converts a handler returning `Err` into a 500 response, with the error message written to application logs. + + + + +Create a project directory and install the SDK: + +```sh +mkdir outbound-fetch +cd outbound-fetch +npm init -y +npm pkg set type=module +npm install @gcoredev/fastedge-sdk-js +mkdir src wasm +``` + +Create `src/index.js`: + +```js +addEventListener('fetch', async (event) => { + const response = await fetch('https://jsonplaceholder.typicode.com/users'); + const users = await response.json(); + const sliced = users.slice(0, 5); + event.respondWith(new Response(JSON.stringify({ count: sliced.length, users: sliced }), { + headers: { 'content-type': 'application/json' }, + })); +}); +``` + +The handler is async — `await fetch(...)` makes an outbound HTTP call through the WASI outbound-http interface, and `await response.json()` reads and parses the response body. The `fetch` API behaves the same way here as in a browser or Node.js environment: returning a `Response` object with familiar methods like `.json()`, `.text()`, and `.arrayBuffer()`. If the upstream call fails, the unhandled rejection produces a 500 response with the error written to application logs. + + + + +## Build + +Compile the handler to a WebAssembly binary. + + + + +```sh +cargo build --release --target wasm32-wasip2 +``` + +The binary is at `./target/wasm32-wasip2/release/outbound_fetch.wasm`. + + + + +```sh +cargo build --release --target wasm32-wasip1 +``` + +The binary is at `./target/wasm32-wasip1/release/outbound_fetch.wasm`. + + + + +```sh +npx fastedge-build --input src/index.js --output wasm/app.wasm +``` + +The binary is at `./wasm/app.wasm`. + + + + +## Deploy + + + + +1. In the [Gcore Customer Portal](https://portal.gcore.com), navigate to **FastEdge** > **HTTP Applications** > **Applications** and click **Create new application**. +2. Click **Upload binary** and select the `.wasm` file produced in the Build step. +3. Enter a **Name** for the application. +4. Click **Save and deploy**. + +

The application URL appears on the details page. Test it:

+ +```sh +curl https://-.fastedge.app/ +``` + +

The application fetches the upstream API, takes the first five users, and returns them:

+ +```json +{ + "count": 5, + "users": [ + {"id": 1, "name": "Leanne Graham", "username": "Bret", "email": "Sincere@april.biz"}, + {"id": 2, "name": "Ervin Howell", "username": "Antonette", "email": "Shanna@melissa.tv"} + ] +} +``` + +
+ + +

An [API token](/account-settings/api-tokens) is required.

+ +```bash +export GCORE_API_KEY="{YOUR_API_KEY}" +``` + +Do not commit API keys to source control. + +**1. Upload the binary** + + + + +```bash +curl -sX POST 'https://api.gcore.com/fastedge/v1/binaries/raw' \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H 'Content-Type: application/octet-stream' \ + --data-binary "@./target/wasm32-wasip2/release/outbound_fetch.wasm" +``` + + + + +```bash +curl -sX POST 'https://api.gcore.com/fastedge/v1/binaries/raw' \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H 'Content-Type: application/octet-stream' \ + --data-binary "@./target/wasm32-wasip1/release/outbound_fetch.wasm" +``` + + + + +```bash +curl -sX POST 'https://api.gcore.com/fastedge/v1/binaries/raw' \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H 'Content-Type: application/octet-stream' \ + --data-binary "@./wasm/app.wasm" +``` + + + + +```json +{"id": 4696, "api_type": "wasi-http", "status": 1} +``` + +**2. Create the application** + +```bash +export BINARY_ID=4696 + +curl -sX POST 'https://api.gcore.com/fastedge/v1/apps' \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H 'Content-Type: application/json' \ + -d "{\"name\": \"my-outbound-fetch\", \"binary\": $BINARY_ID, \"status\": 1}" +``` + +**3. Test** + +

The URL from the create-app response becomes active within a few seconds:

+ +```bash +curl https://my-outbound-fetch-1000503.fastedge.app/ +``` + +

The application fetches the upstream API, takes the first five users, and returns them:

+ +```json +{ + "count": 5, + "users": [ + {"id": 1, "name": "Leanne Graham", "username": "Bret", "email": "Sincere@april.biz"}, + {"id": 2, "name": "Ervin Howell", "username": "Antonette", "email": "Shanna@melissa.tv"} + ] +} +``` + +
+
+ +The outbound call happens on every request, from every edge node that handles traffic for this app. For data that changes infrequently, storing the upstream response in a [KV store](/fastedge/kv-stores/manage-kv-store) eliminates per-request latency after the first fetch. diff --git a/fastedge/getting-started/cdn-properties.mdx b/fastedge/getting-started/cdn-properties.mdx index 2ce0cb285..090b54b7c 100644 --- a/fastedge/getting-started/cdn-properties.mdx +++ b/fastedge/getting-started/cdn-properties.mdx @@ -1,100 +1,75 @@ --- -title: "CDN properties" -sidebarTitle: "CDN properties" -ai-navigation: Access and modify HTTP request and response properties in Gcore CDN Proxy-Wasm applications via read-write properties like path, host, queryString and read-only properties like scheme, method, country, city, ASN, latitude, longitude, region, continent deciphered from client IP. +title: "Request and response properties" +sidebarTitle: "Request and response properties" +ai-navigation: Reference for HTTP request and response properties available in FastEdge CDN Proxy-Wasm applications. Covers get_property and set_property paths, access modes per hook, and custom properties for passing state within a processing phase. --- -CDN applications built on the Proxy-Wasm ABI interact with HTTP requests and responses through a property system. Since each hook (onRequestHeaders, onRequestBody, onResponseHeaders, onResponseBody) runs in its own isolated WASM instance, properties provide the mechanism for reading request/response data and modifying CDN behavior throughout the request lifecycle. +FastEdge CDN applications read and modify request and response data through the `get_property` and `set_property` host functions. The table below lists all properties accessible through this API. HTTP headers are read and written through dedicated header methods (`get_http_request_header`, `set_http_response_header`, etc.) and are not included here. + +## Available properties + +| Property path | Type | Access | Available in | Description | +|---|---|---|---|---| +| `request.url` | String | Read-write | `on_http_request_headers` | Original URL path before modifications | +| `request.host` | String | Read-write | `on_http_request_headers` | Host header value | +| `request.path` | String | Read-write | `on_http_request_headers` | Request URL path | +| `request.scheme` | String | Read-only | `on_http_request_headers` | Protocol scheme (`http` or `https`) | +| `request.method` | String | Read-only | `on_http_request_headers` | HTTP method | +| `request.extension` | String | Read-only | `on_http_request_headers` | File extension from the request path | +| `request.query` | String | Read-write | `on_http_request_headers` | Query string | +| `request.country` | String | Read-only | `on_http_request_headers` | Two-letter country code, derived from client IP | +| `request.city` | String | Read-only | `on_http_request_headers` | City name, derived from client IP | +| `request.asn` | String | Read-only | `on_http_request_headers` | ASN of the network associated with the client IP | +| `request.geo.lat` | String | Read-only | `on_http_request_headers` | Latitude, derived from client IP | +| `request.geo.long` | String | Read-only | `on_http_request_headers` | Longitude, derived from client IP | +| `request.region` | String | Read-only | `on_http_request_headers` | Region, derived from client IP | +| `request.continent` | String | Read-only | `on_http_request_headers` | Continent, derived from client IP | +| `request.country.name` | String | Read-only | `on_http_request_headers` | Country name, derived from client IP | +| `nginx.log_field1` | String | Write-only | `on_http_request_headers` | Appends a value to the CDN access log. Requires [Log Uploader](https://gcore.com/docs/cdn/logs/export-cdn-resource-logs-to-your-storage). | +| `response.status` | Integer | Read-only | `on_http_response_headers`, `on_http_response_body` | HTTP response status code | + +Property paths are case-sensitive. + +The following example reads the client country and conditionally sets the log field: -### How properties work - -Properties are accessed through two core methods: - -- **`get_property(path)`**: Reads data from the current request context -- **`set_property(path, value)`**: Modifies writable properties to customize CDN behavior - -Each property is identified by a path (e.g., `request.path`, `response.status`) and has specific access permissions based on the hook where it's accessed. - -### Property access patterns - -**Read-only properties**: Can be read but not modified. These typically represent immutable request data or CDN internal state. - -**Read-write properties**: Can be both read and modified. Use these to customize headers, adjust routing, or modify response behavior. - -**Hook-specific availability**: Some properties are only accessible in certain hooks. For example, response properties are unavailable in request hooks. - -### Available properties - -The following table lists all available properties and their access permissions. These properties can only be written to within the onRequestHeaders hook: - -| Property Path | Type | Access | Description | -| ---------------------- | ------- | ---------- | ----------------------------------------------------- | -| `request.url` | String | Read-write | Original URL path before modifications | -| `request.host` | String | Read-write | Host header value | -| `request.path` | String | Read-write | Request URL path | -| `request.scheme` | String | Read-only | Protocol scheme (http/https) | -| `request.method` | String | Read-only | HTTP method (GET, POST, etc.) | -| `request.extension` | String | Read-only | Request path extension | -| `request.query` | String | Read-write | Query string parameters | -| `request.country` | String | Read-only | Country Code - deciphered from IP | -| `request.city` | String | Read-only | City name - deciphered from IP | -| `request.asn` | String | Read-only | ASN of the network/ISP associated with the request IP | -| `request.geo.lat` | String | Read-only | Latitude - deciphered from IP | -| `request.geo.long` | String | Read-only | Longitude - deciphered from IP | -| `request.region` | String | Read-only | Region - deciphered from IP | -| `request.continent` | String | Read-only | Continent - deciphered from IP | -| `request.country.name` | String | Read-only | Country name - deciphered from IP | -| `nginx.log_field1` | String | Write-only | Adds value to nginx access logs | -| `response.status` | Integer | Read-only | HTTP status code | - - -#### `nginx.log_field1` - -This field is write-only (onRequestHeaders). Adding a value here will ensure it is written to CDN access log, available through the Log uploader feature. +```rust +fn on_http_request_headers(&mut self, _: usize, _: bool) -> Action { + if let Some(country) = self.get_property(vec!["request.country"]) { + let code = String::from_utf8_lossy(&country); + self.set_property(vec!["nginx.log_field1"], Some(code.as_bytes())); + } + Action::Continue +} +``` +## Custom properties -### Custom properties +Applications can define custom properties to pass state between related hooks. For example, a property set in `on_http_response_headers` is readable in `on_http_response_body`. -You can also create custom properties within hooks. This allows you to track data between hook runs. e.g. custom property `markdown` -These custom hooks are all read-write, however they are only available from onRequestBody onwards. Anything added within onRequestHeaders will **not** be available, in future hooks. + +Custom properties created in `on_http_request_headers` are not available in later hooks. + -### Example: Response modification +The following example marks a response as Markdown in `on_http_response_headers` and reads that flag in `on_http_response_body`: ```rust -// In onResponseHeaders -fn on_response_headers() { - // Add Custom markdown property +fn on_http_response_headers(&mut self, _: usize, _: bool) -> Action { if let Some(content_type) = self.get_http_response_header("Content-Type") { if content_type.starts_with("text/plain") || content_type.starts_with("text/markdown") { self.set_http_response_header("Content-Length", None); - self.set_http_response_header("Transfer-Encoding", Some("Chunked")); + self.set_http_response_header("Transfer-Encoding", Some("chunked")); self.set_http_response_header("Content-Type", Some("text/html")); self.set_property(vec!["response.markdown"], Some(b"true")); - println!("Response is markdown, on_response_body can now convert to HTML"); } } + Action::Continue } -// In onResponseBody -fn on_http_response_body(&mut self, body_size: usize, end_of_stream: bool) -> Action { - // only process markdown - if None == self.get_property(vec!["response.markdown"]) { +fn on_http_response_body(&mut self, _: usize, _: bool) -> Action { + if self.get_property(vec!["response.markdown"]).is_none() { return Action::Continue; } + // convert body to HTML here + Action::Continue } ``` - -### Property modification best practices - -**Validate before setting**: Always validate property values before modification to prevent errors. - -**Use appropriate hooks**: Modify request properties only in onRequestHeaders. - -**Handle missing properties**: Not all properties are available in all contexts. Use error handling when accessing optional properties. - - -**Note** - -Property paths are case-sensitive. Header names follow HTTP conventions (lowercase with hyphens). - - diff --git a/fastedge/getting-started/create-fastedge-apps.mdx b/fastedge/getting-started/create-fastedge-apps.mdx index 65608358a..614451f9e 100644 --- a/fastedge/getting-started/create-fastedge-apps.mdx +++ b/fastedge/getting-started/create-fastedge-apps.mdx @@ -1,532 +1,366 @@ --- title: Create FastEdge HTTP applications sidebarTitle: HTTP applications -ai-navigation: Create FastEdge HTTP applications by uploading custom WebAssembly binaries built with JavaScript SDK or Rust SDK, or by deploying preconfigured templates via Gcore Customer Portal or API. +ai-navigation: Create FastEdge HTTP applications by uploading custom WebAssembly binaries built with JavaScript SDK or Rust SDK, or by deploying preconfigured templates via Gcore Customer Portal or REST API. --- -This guide describes how to create a FastEdge app. Check out our [FastEdge overview](/fastedge/getting-started) article to learn more about the product. +import { MethodSwitch, MethodSection } from "/snippets/method-switch.jsx"; -You can create a FastEdge app in two ways: by uploading a custom binary file (built using the [JavaScript SDK](https://github.com/G-Core/FastEdge-sdk-js) or [Rust](https://github.com/G-Core/FastEdge-sdk-rust)) or by using a preconfigured template. If you use a template, skip Stage 1. + + -## Stage 1. Create a Wasm binary file +FastEdge HTTP applications run on Gcore's edge network and respond to HTTP requests via a dedicated URL. An application is deployed from a compiled WebAssembly binary — built using the [JavaScript SDK](https://github.com/G-Core/FastEdge-sdk-js) or [Rust SDK](https://github.com/G-Core/FastEdge-sdk-rust) — or from a preconfigured template. Templates require no binary build step. -To get started, create a .wasm file that you will later upload to the Gcore Customer Portal. +## Step 1. Build a Wasm binary + +

Skip this step when deploying from a template — go directly to [Step 2](#step-2-deploy-the-application).

- - #### Step 1. Set up the environment + - 1\. Install the Rust compiler and cargo (package manager): +

Required: [Rust and Cargo](https://rustup.rs). On Windows, also install [Visual Studio Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022) with the **Desktop development with C++** workload.

- ```sh - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - ``` +1. Add the Wasm compilation target: - 2\. Add the Wasm compilation target to Rust compiler: + ```sh + rustup target add wasm32-wasip2 + ``` - ```sh - rustup target add wasm32-wasip1 - ``` +2. Scaffold an application from the `http-base` template: - #### Step 2. Prepare the directory structure and a configuration file + ```sh + npm create fastedge-app@latest my-rust-app -- --rust --template http-base --no-verify + ``` - 1\. Initialize the directory structure: +3. Build the Wasm binary: - ```sh - cargo new myapp --lib - ``` + ```sh + cd my-rust-app + cargo build --release + ``` - 2\. Create a directory: +

The Wasm file is written to `./target/wasm32-wasip2/release/basic_wasi_http.wasm`. Upload this file in Step 2.

- ```sh - mkdir myapp/.cargo - ``` +
+ - 3\. Set the Wasm compilation target for the project by creating a config file `myapp/.cargo/config.toml` with the following content: +

Required: [Node.js](https://nodejs.org).

- ```toml - [build] - target = "wasm32-wasip1" - ``` +1. Scaffold an application from the `http-base` template: - 4\. Create the project manifest file `myapp/Cargo.toml` with the following content: + ```sh + npm create fastedge-app@latest my-first-app -- --javascript --template http-base --no-verify + ``` - ```toml - [package] - name = "myapp" - version = "0.1.0" - edition = "2021" +2. Build the Wasm binary: - [lib] - crate-type = ["cdylib"] + ```sh + cd my-first-app + npm install + npm run build + ``` - [dependencies] - fastedge = "0.2" - ``` +

The Wasm file is written to `./wasm/basic-http.wasm`. Upload this file in Step 2.

- #### Step 3. Create a source +
+
- In this example, we'll create a simple app that responds with "HTTP 200" and the text "Hello world!" in the response's body. You can find more examples in the [Gcore repository](https://github.com/G-Core/FastEdge-examples/tree/main/rust). +## Step 2. Deploy the application - Create a main source file src/lib.rs with the following content: +

Two deployment methods are available: from a custom binary built in Step 1, or from a preconfigured template — no binary is required for templates.

- ``` - use fastedge::{ - body::Body, - http::{Request, Response, StatusCode, Error}, - }; +### From a binary - #[fastedge::http] - fn main(_req: Request) -> Result, Error> { - Response::builder() - .status(StatusCode::OK) - .body(Body::from("Hello world!\n")) - } - ``` +

Use this method when deploying a Wasm binary built with the Rust or JavaScript SDK in Step 1.

- #### Step 4. Compile a Wasm file +1. In the [Gcore Customer Portal](https://portal.gcore.com), navigate to **FastEdge** > **HTTP Applications** > **Applications** and click **Create new application**. - Produce the Wasm binary: + ![HTTP Applications list with the Create new application button](/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-list-create-button.png) - ```sh - cargo build --release - ``` +2. On the **Create an application** page, click the **Upload binary** card. - The resulting Wasm code will be written to the `myapp/target/wasm32-wasip1/release/myapp.wasm` file. + ![Create an application page with the Upload binary card](/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-upload-binary.png) - - - A JavaScript code pattern closely resembles [Service Worker API](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API). You can also find multiple examples in the [Gcore repository](https://github.com/G-Core/FastEdge-examples/tree/main/javascript). +3. In the **Upload binary** dialog, click **Click to upload or drag and drop** and select the `.wasm` file. The portal processes the upload and opens the **Deploy application** page. - The key aspect of the Wasm configuration is to set up the `addEventListener` that has to synchronously call `event.respondWith` with a callback. This callback can be asynchronous and this is where you'd usually include any custom code to generate a response. + ![Create application page with Upload binary option selected](/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-upload-binary.png) - Here's the sample app source: +4. Enter a **Name** for the application and an optional description. - ```js - async function app(event) { - const request = event.request; - return new Response(`You made a request to ${request.url}`); - } - addEventListener('fetch', (event) => { - event.respondWith(app(event)); - }); - ``` - - Run the command `npm create fastedge-app my-first-app`. - - For first-time setup select the following options: - ``` - $ npm create fastedge-app my-first-app - ┌ create-fastedge-app - │ - ◇ Creating in provided directory: ./my-first-app - │ - ◇ Select programming language: - │ TypeScript - │ - ◇ Language: typescript - │ - ◇ Select a template: - │ http-base - │ - ◆ Do you want to continue? - │ ● Yes / ○ No - - ``` +5. (Optional) In the **Response headers** section, click **Add response header** to add static headers to every HTTP response. Common uses: CORS (`Access-Control-Allow-Origin: *`), security headers (`X-Frame-Options: DENY`), custom cache directives. - - +6. (Optional) In the **Environment variables** section, click **Add environment variable** and enter key-value pairs. The application reads these values at runtime using the FastEdge SDK — for example, `getEnv('API_ENDPOINT')` in JavaScript or `std::env::var("API_ENDPOINT")` in Rust. Use for configuration that changes between deployments without rebuilding the binary. -## Stage 2. Deploy an application +7. (Optional) In the **Secrets** section, click **Add secret** to attach an encrypted value for sensitive data such as API keys or tokens. The app accesses it as a regular environment variable — the key set here becomes the variable name. A secret must exist in [Secrets Manager](/fastedge/secrets-manager/manage-secrets) before it can be attached. -For detailed steps on how to deploy a FastEdge app, refer to the relevant sections below: +8. (Optional) In the **Edge Storage** section, click **Add Edge Storage** to attach a key-value store the application can query at the edge without hitting the origin server. The store must exist on the [Edge Storage](/fastedge/kv-stores/manage-kv-store) page before it can be attached. -- [In the Customer Portal](/fastedge/getting-started/create-fastedge-apps#in-the-customer-portal). Follow the instructions if you created a custom Wasm using either the Rust or Javascript SDK, or if you want to create a FastEdge app from a preconfigured template. + ![Deploy application form with response headers and environment variables sections](/images/docs/fastedge/getting-started/create-fastedge-apps/deploy-form-config-sections.png) -- [Via command line](/fastedge/getting-started/create-fastedge-apps#via-command-line): Follow the instructions if you want to deploy a custom Wasm using cURL and our API. +9. Click **Save and deploy**. -### In the customer portal +

The application details page opens with the deployment URL.

- - - 1\. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge** > **HTTP Applications**. +![Application details page with URL and Active status](/images/docs/fastedge/getting-started/create-fastedge-apps/http-app-details-url-active.png) - 2\. In the top-right corner of the screen, click **Create new application**. +### From a template - ![Create an HTTP app button highlighted](/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-create-app.png) +

Use this method to deploy a built-in or custom template without writing or building any code.

- 3\. Click **Upload binary**. +1. In the Customer Portal, navigate to **FastEdge** > **HTTP Applications** > **Applications** and click **Create new application**. - ![Add raw binary dialog](/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-upload-binary.png) + ![HTTP Applications list with the Create new application button](/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-list-create-button.png) - 4\. Choose your custom binary file. +2. Scroll to the **Create from a template** section and select a template. Built-in templates are **Geolocation-based redirect** and **Markdown renderer**. To deploy from a custom template, create it first on the **HTTP Applications** > **Templates** page as described in [custom templates](/fastedge/create-manage-templates). - ![Add raw binary dialog](/images/docs/fastedge/getting-started/create-fastedge-apps/upload-binary-dialog.png) + ![Create from a template section with Geolocation-based redirect and Markdown renderer](/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-create-from-template.png) - 5\. Enter a name for your application and provide a description if needed. +3. Enter a **Name** for the application and an optional description. - 6\. (Optional) Click **\+ Add response headers** to add fixed headers to the responses. For example, you may include CORS (cross-origin resource sharing) headers in each response to ensure secure communication between origins. +4. Fill in the **Template environment variables** required by the selected template: - 7\. (Optional) If you want to customize the behavior of your application, click **\+ Add environment variables** and enter your data as key-value pairs. + **Markdown renderer** - ![A page with a link to an app and its configuration](/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-create-app-env-vars.png) + - **BASE** (required): Base URL for Markdown source files. Example: `https://raw.githubusercontent.com/G-Core/FastEdge-sdk-js/main/` + - **HEAD** (optional): HTML inserted into the `` tag. Example: `` - - **Info** + **Geolocation-based redirect** - If you're adding sensitive information or want to ensure that any data in the app's configuration remains secure, click **\+ Add Secret** and use the Secrets Manager. - + - **DEFAULT** (required): Fallback redirect URL for visitors whose country does not match any rule. Example: `https://example.com/fallback` + - In the **Environment variables** section, add ISO 3166-1 alpha-2 country codes as keys with redirect URLs as values. Example: key `LU`, value `https://example.com/luxembourg`. - 8\. Check all the settings. If everything is configured correctly, click **Save and deploy**. +5. (Optional) Configure additional sections: - Your application has been successfully deployed. + - **Response headers**: static headers added to every response (e.g., CORS or security headers). + - **Environment variables**: runtime key-value pairs the application reads via the SDK. These are separate from the template-defined variables above. + - **Secrets**: encrypted values for sensitive data such as API keys. The app accesses a secret as an environment variable using the key name set here. Requires an existing secret in Secrets Manager. + - **Edge Storage**: a key-value store the app queries at the edge. Requires an existing store on the **FastEdge** > **Edge Storage** page. - ![A page with a link to an app and its configuration](/images/docs/fastedge/getting-started/create-fastedge-apps/http-app-created.png) + ![Deploy application form with template environment variables](/images/docs/fastedge/getting-started/create-fastedge-apps/template-deploy-env-vars-form.png) - You can now test its configuration and adjust it as described in the following steps. +6. Click **Save and deploy**. -
- - 1\. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge** > **HTTP Applications**. +

The application details page opens with the deployment URL.

- 2\. In the top-right corner of the screen, click **Create new application**. +![Application details page after template deployment](/images/docs/fastedge/getting-started/create-fastedge-apps/http-app-details-url-active.png) - ![Section with Github and Markdown templates](/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-create-app.png) +## Step 3. Test the application - 3\. In the **Create from a template** section, select the preferred template. +

Click the URL at the top of the application details page to open the application in a browser, or test with curl:

- ![Section with Github and Markdown templates](/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-create-from-template.png) +```sh +curl -i https://-.fastedge.app/ +``` - 4\. Enter a name for your application and, optionally, update its description. +

To find the URL later, navigate to **FastEdge** > **HTTP Applications** > **Applications** and check the **URL** column.

- 5\. Provide environment variables or any required configuration for your app. Note that the list of setup options depends on the selected template. For example, if you create a FastEdge app from a Markdown template, you need to add response headers, enter the base part of the origin URL, and add content from the `` section of an HTML document. +![HTTP Applications list with Name, URL, and Status columns](/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-application-list-edge-storage.png) - 6\. (Optional) If you want to add metadata to the configuration, click **\+ Add environment variables** and enter metadata as key-value pairs. +
+ - ![A page with a link to an app and its configuration](/images/docs/fastedge/getting-started/create-fastedge-apps/http-app-from-template-setup.png) +Deploy a compiled WebAssembly application to the FastEdge edge network using the [Python SDK](/developer-tools/sdks/python), [Go SDK](/developer-tools/sdks/go), or curl. - 7\. Click **Save and deploy**. + +An [API token](/account-settings/api-tokens) from the Gcore Customer Portal is required. + - Your application has been successfully deployed. +

Set this variable before running the examples:

- ![A page with a link to an app and its configuration](/images/docs/fastedge/getting-started/create-fastedge-apps/http-app-created-from-template.png) +```bash +export GCORE_API_KEY="{YOUR_API_KEY}" +``` - You can now test its configuration and adjust it as described in the following steps. +## Step 1. Build a Wasm binary - - +

Build the binary using the Rust or JavaScript SDK. Set `WASM_PATH` at the end of the tab — it is used in Step 2.

-### Via command line + + -1\. Upload the Wasm binary to our edge servers by running the following [API request](/api-reference/fastedge/binaries/store-compiled-wasm-binary) from the repo's root directory. Insert your [permanent API token](/account-settings/api-tokens) instead of the api_key: +

Required: [Rust and Cargo](https://rustup.rs). On Windows, also install [Visual Studio Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022) with the **Desktop development with C++** workload.

-```sh -curl -X 'POST' - 'https://api.gcore.com/fastedge/v1/binaries/raw' \ - -H 'accept: application/json' - -H 'Authorization: APIKey api_key' - -H 'Content-Type: application/octet-stream' - --data-binary '@./dist/main.wasm' +```bash +rustup target add wasm32-wasip2 +npm create fastedge-app@latest my-rust-app -- --rust --template http-base --no-verify +cd my-rust-app && cargo build --release +export WASM_PATH="./target/wasm32-wasip2/release/basic_wasi_http.wasm" ``` -In the response, you will receive the ID of the uploaded binary (``). Make sure to save it, as it will be used in the following step. +
+ -2\. Create the app by running the following [API request](/api-reference/fastedge/apps/add-a-new-app): +

Required: [Node.js](https://nodejs.org).

-```sh -curl -X 'POST' - 'https://api.gcore.com/fastedge/v1/apps' - -H 'name: app_name' - -H 'accept: application/json' - -H 'client_id: 0' - -H 'Authorization: APIKey api_key' - -H 'Content-Type: application/json' - -d '{ - "binary": binary_id, - "plan": "beta", - "status": 1 -}' +```bash +npm create fastedge-app@latest my-first-app -- --javascript --template http-base --no-verify +cd my-first-app && npm install && npm run build +export WASM_PATH="./wasm/basic-http.wasm" ``` -Where: +
+
-- `app_name` is the unique name of your app. -- `api_key` is your permanent API token. -- `binary_id` is the ID of your uploaded Wasm binary. +## Step 2. Deploy the application -## Stage 3. Test an application +

Deploying requires two calls: upload the binary, then create the application referencing the returned binary ID.

-You can test the application after its deployment by clicking the application link on the deployment confirmation screen: +**1. Upload the binary** - - ![A page with a link to an app and its - configuration](/images/docs/fastedge/getting-started/create-fastedge-apps/test-http-app.png) - +| Parameter | Required | Description | +|-----------|----------|-------------| +| Request body | Yes | Raw Wasm binary as `application/octet-stream` | -Additionally, you can inspect and adjust the configuration in the Customer Portal on the **HTTP Applications** page: + + -1\. In the Gcore Customer Portal, navigate to **FastEdge** > **HTTP Applications** > **Applications**. +```python +import os +from gcore import Gcore - - ![HTTP Applications with the list of FastEdge - apps](/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-application-list.png) - +client = Gcore(api_key=os.environ["GCORE_API_KEY"]) -2\. Find the app you want to test and click its name to open it. +with open(os.environ["WASM_PATH"], "rb") as f: + binary = client.fastedge.binaries.create(f) -3\. Click the app link next to the app status to view the response. +# binary.id is needed for the next call +print("Binary ID:", binary.id) +``` - - ![A page with a link to an app and its - configuration](/images/docs/fastedge/getting-started/create-fastedge-apps/test-http-app.png) - + + -For example, the response for the application configured in Stage 1 will be "Hello world!". +```go +package main -## Stage 4 (Optional). Add more functionality +import ( + "context" + "fmt" + "os" -You can add more functionality to your app. For example, instead of printing "Hello world!", the app can print all request headers and set a custom response header from the environment settings. Let's see how to do that. + gcore "github.com/G-Core/gcore-go" + "github.com/G-Core/gcore-go/option" +) - - - #### Step 1. Change the source - - To print all request headers and develop a custom response header, replace the current content of the `myapp/src/lib.rs` file with the following: - - ``` - use fastedge::{ - body::Body, - http::{Request, Response, StatusCode, Error}, - }; - use std::env; - - #[fastedge::http] - fn main(req: Request) -> Result, Error> { - // print headers - let mut body: String = "".to_string(); - for (h, v) in req.headers() { - body.push_str(h.as_str()); - body.push_str(": "); - match v.to_str() { - Err(_) => body.push_str("not a valid text"), - Ok(a) => body.push_str(a), - } - body.push_str("\n"); - } - - // get value for custom header from the env var - let value = match env::var("CUSTOM_HEADER").ok() { - None => return Response::builder() - .status(StatusCode::INTERNAL_SERVER_ERROR) - .body(Body::from("App misconfigured\n")), - Some(val) => val - }; - - // build response with body and custom header - Response::builder() - .status(StatusCode::OK) - .header("Custom-Header", value) - .body(Body::from(body)) +func main() { + client := gcore.NewClient(option.WithAPIKey(os.Getenv("GCORE_API_KEY"))) + + f, err := os.Open(os.Getenv("WASM_PATH")) + if err != nil { + panic(err) } - ``` - - - **Info** - - The headers listed in the following step are passed to the FastEdge application, which uses the header content for functionalities like geolocation-aware redirects. - - - #### Step 2. Compile and upload the binary file - - Update the application on the edge servers: - - 1\. Compile a new Wasm file [as described in stage 1](/fastedge/getting-started/create-fastedge-apps#step-4-compile-a-wasm-file). - - 2\. Upload it to the Gcore Customer Portal as a custom binary file. - - When you open the app, you'll see all request headers from the environment settings. It will be similar to the following output: - - ```sh - HTTP/2 200 - server: nginx - date: Thu, 19 Oct 2023 22:17:46 GMT - content-length: 616 - custom-header: foo - access-control-allow-origin: * - cache-control: no-store - x-id: ed-hw-edge-preprod-gc39 - cache: MISS - accept-ranges: bytes - dc: ed - geoip-asn: 7922 - geoip-lat: 37.75580 - geoip-long: -121.95270 - geoip-reg: CA - geoip-city: San Ramon - geoip-continent: NA - geoip-country-name: United States - geoip-country-code: US - server_addr: 92.223.112.26 - server_name: mistake-globe-6396.fastedge.gcore.dev - connection: upgrade - x-real-ip: 1.2.3.4 - x-forwarded-for: 1.2.3.4 - host: fastedge.gcore.dev - x-forwarded-proto: https - user-agent: curl/7.88.1 - accept: */* - cdn-loop: nb1d2; c=11 - pop-long: 6.1294 - pop-lat: 49.6113 - pop-reg: LU - pop-continent: EU - pop-city: Luxembourg - pop-country-code: LU - pop-country-name: Luxembourg - ``` - - - * custom-header: Custom header - * dc: Data center - * geoip-*: Client GeoIP data, such as asn, latitude, longitude, region, city, continent, country name, and country code - * server_addr: PoP IP address - * server_name: Application hostname - * x-forwarded-for: Client IP address - * pop-*: PoP GeoIP data, such as asn, latitude, longitude, region, city, continent, country name, and country code - + defer f.Close() + + binary, err := client.Fastedge.Binaries.New(context.TODO(), f) + if err != nil { + panic(err) + } + // binary.ID is needed for the next call + fmt.Println("Binary ID:", binary.ID) +} +``` - - You can add more functionality to your app. For example, instead of printing "You made a request to /", the app can print all request headers and set a custom response header from the environment settings. + - #### Step 1. Print request headers and add custom response header +```bash +curl -sX POST 'https://api.gcore.com/fastedge/v1/binaries/raw' \ + -H 'Authorization: APIKey $GCORE_API_KEY' \ + -H 'Content-Type: application/octet-stream' \ + --data-binary "@$WASM_PATH" +``` - Replace the sample configuration in the `src/input.js` with the following code: +

The API returns:

- ```js - import { getEnv } from 'fastedge::env'; +```json +{"id": 4683, "api_type": "wasi-http", "status": 1, "checksum": "ba9dae6f9e5850833cd1929170916f2b"} +``` - async function eventHandler(event) { - const request = event.request; - const customEnvVariable = getEnv('MY_CUSTOM_ENV_VAR'); - const headersStr = JSON.stringify(Object.fromEntries(request.headers.entries()), null, 2); +```bash +export BINARY_ID="{id}" # replace with the id from the response above +``` - return new Response(`Headers: ${headersStr}\n`, { - headers: { - 'Custom-Header': customEnvVariable, - }, - }); - } +
+
- addEventListener('fetch', (event) => { - event.respondWith(eventHandler(event)); - }); - ``` - - The application logic (e.g., location-aware redirection) assumes the use of the headers listed in the following steps. The headers may change in the future. - - #### Step 2. Compile a new Wasm binary - - Run the command you used in the Stage 1: `npx fastegde-build ./src/input.js ./dist/main.wasm` - - #### Step 3. Compile a new Wasm binary - - Upload the new Wasm file to the edge servers with the same API request you executed in Stage 2: - - ```sh - curl -X 'POST' - 'https://api.gcore.com/fastedge/v1/binaries/raw' - -H 'accept: application/json' - -H 'Authorization: APIKey api_key' - -H 'Content-Type: application/octet-stream' - --data-binary '@./dist/main.wasm' - ``` - - Don't forget to save the ID of the new Wasm binary, as you'll need to use it in the following step. - - #### Step 4. Update the app - - Run the following API request: - - ```sh - curl -X 'PUT' - 'https://api.gcore.com/fastedge/v1/apps/app_id' - -H 'accept: application/json' - -H 'Authorization: APIKey api_key' - -H 'Content-Type: application/json' - -d '{ - "binary": new_binary_id, - "plan": "beta", - "status": 1, - "name": app_name, - "env": { - "MY_CUSTOM_ENV_VAR": "Custom-Header-Value" - } - }' - ``` - - Where: - - * app_name is the unique name of your app. - * app_id is the app ID. - * api_key is your [permanent API token](/account-settings/api-tokens). - * binary_id is the ID of your uploaded Wasm binary. - - - - #### Step 5. Test the app - - Run the following curl request: `curl https://.fastedge.gcore.dev/`, where `` is the name of your application indicated in the previous step. - - If everything is updated correctly, the response will be: - - ```json - { - "Headers": { - "dc": "ed", - "my-custom-header": "Custom-Header-Value", - "geoip-asn": "199524", - "geoip-lat": "49.61130", - "geoip-long": "6.12940", - "geoip-reg": "LU", - "geoip-city": "Luxembourg", - "geoip-continent": "EU", - "geoip-country-name": "Luxembourg", - "geoip-country-code": "LU", - "server_addr": "192.2.3.4", - "server_addrserver_name": "bear-wiggle-4732724.fastedge.gcore.dev", - "connection": "upgrade", - "x-real-ip": "1.2.3.4", - "x-cdn-requestor": "ed-hw-edge-preprod-gc39", - "server_addrx-forwarded-for": "1.2.3.4", - "host": "fastedge.gcore.dev", - "x-forwarded-proto": "https", - "user-agent": "curl/7.81.0", - "cdn-loop": "nb1d2; c=11", - "server_addrpop-country-code": "LU", - "server_addrpop-reg": "LU", - "server_addrpop-country-name": "Luxembourg", - "server_addrpop-lat": "49.6113", - "server_addrpop-long": "6.1294", - "server_addrpop-continent": "EU", - "server_addrpop-city": "Luxembourg" - } - } - ``` - - - * my-custom-header: Added custom header - * dc: Data center - * geoip-*: Client GeoIP data, such as asn, latitude, longitude, region, city, continent, country name, and country code - * server_addr: PoP IP address - * server_name: Application hostname - * x-forwarded-for: Client IP address - * pop-*: PoP GeoIP data, such as asn, latitude, longitude, region, city, continent, country name, and country code - +**2. Create the application** + +| Parameter | Required | Description | +|-----------|----------|-------------| +| `name` | Yes | Unique application name (lowercase letters, numbers, and hyphens) | +| `binary` | Yes | Binary ID from the upload response | +| `status` | Yes | `1` — enabled, `0` — disabled | + + + + +```python +app = client.fastedge.apps.create( + name="my-edge-app", + binary=binary.id, + status=1, +) +print("App URL:", app.url) +``` + + + + +```go +import ( + "github.com/G-Core/gcore-go/fastedge" + "github.com/G-Core/gcore-go/packages/param" +) + +app, err := client.Fastedge.Apps.New(context.TODO(), fastedge.AppNewParams{ + App: fastedge.AppParam{ + Name: param.NewOpt("my-edge-app"), + Binary: param.NewOpt(binary.ID), + Status: param.NewOpt(int64(1)), + }, +}) +if err != nil { + panic(err) +} +fmt.Println("App URL:", app.URL) +``` + + + + +```bash +curl -sX POST 'https://api.gcore.com/fastedge/v1/apps' \ + -H 'Authorization: APIKey $GCORE_API_KEY' \ + -H 'Content-Type: application/json' \ + -d "{\"name\": \"my-edge-app\", \"binary\": $BINARY_ID, \"status\": 1}" +``` + +

The API returns:

+ +```json +{"id": 2543, "name": "my-edge-app", "url": "https://my-edge-app-1000503.fastedge.app", "status": 1, "binary": 4683, "api_type": "wasi-http", "plan": "Free"} +```
-## Troubleshoot an application +## Step 3. Test the application + +

The deployment URL becomes active within a few seconds of creation. Send a request to the `url` from the create-app response:

+ +```bash +curl -i https://-.fastedge.app/ +``` + +

The `http-base` template returns a plain-text response:

+ +``` +HTTP/1.1 200 OK +content-type: text/plain;charset=UTF-8 + +Hello from FastEdge! +``` + +
+
-If you're having issues with your FastEdge application, see [Troubleshooting](/fastedge/troubleshooting). diff --git a/fastedge/getting-started/get-started-cdn.mdx b/fastedge/getting-started/get-started-cdn.mdx new file mode 100644 index 000000000..b34e873ce --- /dev/null +++ b/fastedge/getting-started/get-started-cdn.mdx @@ -0,0 +1,126 @@ +--- +title: Build and deploy a FastEdge CDN application +sidebarTitle: Build a CDN app +ai-navigation: Build and deploy a FastEdge CDN application in Rust using Proxy-Wasm via Customer Portal or REST API. +--- + +import { MethodSwitch, MethodSection } from "/snippets/method-switch.jsx"; + +FastEdge CDN applications run inside a CDN resource's request pipeline and can inspect or modify requests and responses as they pass through the CDN. + +Complete the [Rust (CDN / Proxy-Wasm)](/fastedge/getting-started/setup-rust-cdn) setup before proceeding. Once deployed, attach the application to a CDN resource to process live traffic — that step is in [CDN applications](/fastedge/getting-started/integrate-cdn-with-fastedge). + +## Write a handler + +A CDN application consists of two parts: a root context that registers the filter factory, and a filter that implements the callbacks. Replace `src/lib.rs` with: + +```rust +use proxy_wasm::traits::*; +use proxy_wasm::types::*; + +proxy_wasm::main! {{ + proxy_wasm::set_log_level(LogLevel::Info); + proxy_wasm::set_root_context(|_| -> Box { + Box::new(Root) + }); +}} + +struct Root; +impl Context for Root {} +impl RootContext for Root { + fn create_http_context(&self, _: u32) -> Option> { + Some(Box::new(Filter)) + } + fn get_type(&self) -> Option { + Some(ContextType::HttpContext) + } +} + +struct Filter; +impl Context for Filter {} +impl HttpContext for Filter { + fn on_http_request_headers(&mut self, _: usize, _: bool) -> Action { + self.add_http_request_header("x-fastedge", "cdn"); + Action::Continue + } +} +``` + +`Root` registers a new `Filter` for each incoming request via `create_http_context`. `on_http_request_headers` runs when the CDN receives request headers — this example adds a custom `x-fastedge` header and returns `Action::Continue` to pass the request downstream unchanged. To stop the request instead, return `Action::Pause`. + +## Build + +Compile the handler to a WebAssembly binary. The first build downloads dependencies and takes one to two minutes. + +```sh +cargo build --release --target wasm32-wasip1 +``` + +The binary is at `./target/wasm32-wasip1/release/my_cdn_app.wasm`. This file is uploaded to FastEdge in the next step. + +## Deploy + + + + +1. In the [Gcore Customer Portal](https://portal.gcore.com), navigate to **FastEdge** > **CDN Applications** and click **Create new application**. + +![CDN Applications page with Create new application button](/images/docs/fastedge/getting-started/get-started-cdn/cdn-apps-list.png) + +2. Click the **Upload binary** card. + +![Create application page with Upload binary card and template options](/images/docs/fastedge/getting-started/get-started-cdn/cdn-apps-create-options.png) + +3. Select the `.wasm` file produced in the Build step. +4. Enter a **Name** for the application. +5. Click **Save and deploy**. + +

The application is now available in the CDN Applications list. To activate it, attach it to a CDN resource — the full walkthrough is in [CDN applications](/fastedge/getting-started/integrate-cdn-with-fastedge).

+ +
+ + +

Deploying requires two API calls: upload the binary to get its ID, then create the CDN application. An [API token](/account-settings/api-tokens) is required.

+ +```bash +export GCORE_API_KEY="{YOUR_API_KEY}" +``` + +Do not commit API keys to source control. + +### Upload the binary + +```bash +curl -sX POST 'https://api.gcore.com/fastedge/v1/binaries/raw' \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H 'Content-Type: application/octet-stream' \ + --data-binary "@./target/wasm32-wasip1/release/my_cdn_app.wasm" +``` + +

The response contains the binary ID:

+ +```json +{"id": 4695, "api_type": "proxy-wasm", "checksum": "c083e2b6...", "source": 1, "status": 1} +``` + +### Create the application + +```bash +export BINARY_ID=4695 + +curl -sX POST 'https://api.gcore.com/fastedge/v1/apps' \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H 'Content-Type: application/json' \ + -d "{\"name\": \"my-cdn-app\", \"binary\": $BINARY_ID, \"status\": 1}" +``` + +

The response contains the application ID:

+ +```json +{"id": 2553, "name": "my-cdn-app", "binary": 4695, "api_type": "proxy-wasm", "plan": "Free", "plan_id": 30, "status": 1} +``` + +

To activate the application, attach it to a CDN resource. Attachment steps — including the CDN API call — are in [CDN applications](/fastedge/getting-started/integrate-cdn-with-fastedge).

+ +
+
diff --git a/fastedge/getting-started/get-started-http.mdx b/fastedge/getting-started/get-started-http.mdx new file mode 100644 index 000000000..e520cfa23 --- /dev/null +++ b/fastedge/getting-started/get-started-http.mdx @@ -0,0 +1,196 @@ +--- +title: Build a FastEdge HTTP application +sidebarTitle: Build an HTTP app +ai-navigation: Build and deploy a FastEdge HTTP application in Modern Rust, Legacy Rust, or JavaScript via Customer Portal or REST API. +--- + +import { MethodSwitch, MethodSection } from "/snippets/method-switch.jsx"; + +FastEdge HTTP applications respond to HTTP requests directly from the edge. The handler compiles to a WebAssembly binary and runs without servers or containers. Three language options are available — complete the toolchain setup first: [Rust (Modern HTTP)](/fastedge/getting-started/setup-rust-modern), [Rust (Legacy HTTP)](/fastedge/getting-started/setup-rust-legacy), or [JavaScript](/fastedge/getting-started/setup-javascript). + +## Write a handler + +Each language uses a different entry point convention. Choose the tab that matches the toolchain set up earlier. + + + + +Replace `src/lib.rs` with: + +```rust +use wstd::http::body::Body; +use wstd::http::{Request, Response}; + +#[wstd::http_server] +async fn main(request: Request) -> anyhow::Result> { + let url = request.uri().to_string(); + Ok(Response::builder() + .status(200) + .header("content-type", "text/plain;charset=UTF-8") + .body(Body::from(format!("Request received: {url}")))?) +} +``` + + + + +Replace `src/lib.rs` with: + +```rust +use fastedge::body::Body; +use fastedge::http::{Request, Response, StatusCode, Error}; + +#[fastedge::http] +fn main(request: Request) -> Result, Error> { + let url = request.uri().to_string(); + Response::builder() + .status(StatusCode::OK) + .header("content-type", "text/plain;charset=UTF-8") + .body(Body::from(format!("Request received: {url}"))) +} +``` + + + + +Create `src/index.js`: + +```js +addEventListener('fetch', (event) => { + const url = event.request.url; + event.respondWith(new Response(`Request received: ${url}`)); +}); +``` + + + + +## Build + +Compile the handler to a WebAssembly binary. The first build downloads dependencies and takes one to two minutes. + + + + +```sh +cargo build --release --target wasm32-wasip2 +``` + +The binary is at `./target/wasm32-wasip2/release/hello_world.wasm`. + + + + +```sh +cargo build --release --target wasm32-wasip1 +``` + +The binary is at `./target/wasm32-wasip1/release/hello_world.wasm`. + + + + +```sh +npx fastedge-build --input src/index.js --output wasm/app.wasm +``` + +The binary is at `./wasm/app.wasm`. + + + + +## Deploy + + + + +1. In the [Gcore Customer Portal](https://portal.gcore.com), navigate to **FastEdge** > **HTTP Applications** > **Applications** and click **Create new application**. +2. Click **Upload binary** and select the `.wasm` file produced in the Build step. +3. Enter a **Name** for the application. +4. Click **Save and deploy**. + +

The application URL appears on the details page. Test it:

+ +```sh +curl -i https://-.fastedge.app/hello +``` + +
+ + +

Deploying requires two API calls: upload the binary to get its ID, then create the application. An [API token](/account-settings/api-tokens) is required.

+ +```bash +export GCORE_API_KEY="{YOUR_API_KEY}" +``` + +Do not commit API keys to source control. + +**1. Upload the binary** + + + + +```bash +curl -sX POST 'https://api.gcore.com/fastedge/v1/binaries/raw' \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H 'Content-Type: application/octet-stream' \ + --data-binary "@./target/wasm32-wasip2/release/hello_world.wasm" +``` + + + + +```bash +curl -sX POST 'https://api.gcore.com/fastedge/v1/binaries/raw' \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H 'Content-Type: application/octet-stream' \ + --data-binary "@./target/wasm32-wasip1/release/hello_world.wasm" +``` + + + + +```bash +curl -sX POST 'https://api.gcore.com/fastedge/v1/binaries/raw' \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H 'Content-Type: application/octet-stream' \ + --data-binary "@./wasm/app.wasm" +``` + + + + +

The response contains the binary ID:

+ +```json +{"id": 4695, "api_type": "wasi-http", "status": 1} +``` + +**2. Create the application** + +```bash +export BINARY_ID=4695 + +curl -sX POST 'https://api.gcore.com/fastedge/v1/apps' \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H 'Content-Type: application/json' \ + -d "{\"name\": \"my-http-app\", \"binary\": $BINARY_ID, \"status\": 1}" +``` + +

The response contains the application URL:

+ +```json +{"name": "my-http-app", "url": "https://my-http-app-1000503.fastedge.app", "api_type": "wasi-http"} +``` + +**3. Test** + +

The URL becomes active within a few seconds:

+ +```bash +curl -i https://my-http-app-1000503.fastedge.app/hello +``` + +
+
diff --git a/fastedge/getting-started/integrate-cdn-with-fastedge.mdx b/fastedge/getting-started/integrate-cdn-with-fastedge.mdx index 679e00d49..bd4a0b56c 100644 --- a/fastedge/getting-started/integrate-cdn-with-fastedge.mdx +++ b/fastedge/getting-started/integrate-cdn-with-fastedge.mdx @@ -1,9 +1,324 @@ ---- +--- title: "Extend CDN functionality with FastEdge" sidebarTitle: "CDN applications" -ai-navigation: Deploy FastEdge serverless compute functions at CDN edge locations to extend content delivery with custom request/response logic, origin shielding, and dynamic content transformation. +ai-navigation: Integrate FastEdge CDN applications with a Gcore CDN resource to add custom request and response processing via Customer Portal or REST API. --- -import FastEdgeCDNIntegration from "/fastedge/snippets/fastedge-cdn-integration.mdx"; +import { MethodSwitch, MethodSection } from "/snippets/method-switch.jsx"; + + + + +FastEdge CDN applications run inside the CDN request pipeline and modify requests and responses before they reach the origin or client. + +A CDN resource configured for the origin is required. To create one, follow the [CDN resource](/cdn/getting-started/create-a-cdn-resource/overview) guide. + +## How it works + +The CDN runtime invokes a CDN application at five stages of the request lifecycle: + +- **On request headers (before cache):** when the CDN receives request headers, before the cache is checked. +- **On request headers (after cache):** when the CDN receives request headers, after the cache is checked. +- **On request body:** when the CDN receives the request body. +- **On response headers:** before the CDN sends response headers to the client. +- **On response body:** before the CDN sends the response body to the client. + +CDN applications are built on the [Proxy-Wasm](https://github.com/proxy-wasm/spec) specification — an open standard for WebAssembly-based proxy extensions. + +Only one FastEdge application can be attached to each processing stage. + +## Step 1. Create a FastEdge application + +

Deploy an application from a predefined template or upload a custom binary. Custom binaries must conform to the [Proxy-Wasm](https://github.com/proxy-wasm/spec) specification.

+ + + + +

A predefined template is available for JWT authentication. It verifies the JSON Web Token in the request `Authorization` header before the request reaches the origin.

+ +1. In the [Gcore Customer Portal](https://portal.gcore.com), navigate to **FastEdge**. +2. Open the **CDN Applications** page and click **Create new application**. + +![CDN Applications page with Create new application button](/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-apps-page-create-app.png) + +3. In the **Create from a template** section, select **Validate JWT in Authorization header**. + +![Create from a template section showing Validate JWT template option](/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/validate-jwt.png) + +4. Enter a name for the application and, optionally, a description. +5. Add the required environment variables, such as a token signing key for authentication checks. + +![JWT template configuration form with Name and environment variables fields](/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-app-from-template-setup.png) + +6. Click **Save and deploy**. + +

The application is deployed and ready to be linked to a CDN resource.

+ +![Application overview page showing active status](/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-app-created.png) + +

To adjust the configuration later, click **Actions** > **Edit application**.

+ +![Application overview page with Actions menu showing Edit application option](/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/actions-edit-app-from-template.png) + +
+ + +

Custom implementations are available in the [FastEdge-sdk-rust examples](https://github.com/G-Core/FastEdge-sdk-rust/examples) and [proxy-wasm-sdk-as examples](https://github.com/G-Core/proxy-wasm-sdk-as/examples) repositories.

+ +1. In the [Gcore Customer Portal](https://portal.gcore.com), navigate to **FastEdge**. +2. Open the **CDN Applications** page and click **Create new application**. + +![CDN Applications page with Create new application button](/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-apps-page-create-app.png) + +3. Click **Upload binary**. + +![Create application page with Upload binary card](/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-apps-upload-binary.png) + +4. Select the compiled `.wasm` file. + +![File selection dialog for uploading a binary](/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/upload-binary-dialog.png) + +5. Enter a name for the application and, optionally, a description. +6. Add any required environment variables as key-value pairs. For sensitive values, click **+ Add Secret** to store them in [Secrets Manager](/fastedge/secrets-manager/manage-secrets) instead. + +![Custom app configuration form with Name, environment variables, and Secrets fields](/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-app-setup.png) + +7. Click **Save and deploy**. + +

The application is deployed and ready to be linked to a CDN resource. To adjust the configuration later, click **Actions** > **Edit application**.

+ +![Application overview page with Actions menu showing Edit application option](/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/actions-edit-app.png) + +
+
+ +## Step 2. Enable FastEdge for your CDN resource + +

FastEdge can be enabled for all requests on a CDN resource, or limited to specific URL paths using CDN rules.

+ + + + +1. In the Customer Portal, navigate to **CDN**. +2. Find the resource and open its settings. + +![CDN resources list with resource settings button](/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-resource-settings-button.png) + +3. Scroll to the **FastEdge apps** section and enable the toggle for the required stage. + +![CDN resource settings showing FastEdge apps section with event toggles](/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-1.png) + +4. Select the application from the dropdown. + +![FastEdge apps section with On request headers enabled and application dropdown](/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-2.png) + +5. (Optional) Select the **Interrupt request processing in case of error** checkbox. + + +The **Interrupt request processing in case of error** checkbox is enabled by default. When active, errors on the FastEdge side return the relevant response code to the client. When disabled, the CDN ignores the error and forwards the request to the origin. For security-sensitive applications, keep this checkbox enabled. + + +6. Click **Save**. + + + + +

URL-specific rules apply FastEdge logic only to certain paths — for example, protecting `/api/` with JWT validation while leaving other paths unaffected.

+ +1. In the Customer Portal, navigate to **CDN**. +2. Find the resource and open its settings. +3. Click **Rules** > **Create rule**. + +![CDN resource settings with Rules tab open](/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-settings-rules-section.png) + +4. Click **Create blank rule**. +5. Enter a rule name. +6. In the **Match criteria** section, specify the URL paths affected by the application. +7. In the **Options** section, click **Add option**. +8. Scroll to the **FastEdge apps** section and enable the toggle for the required stage. + +![CDN resource settings showing FastEdge apps section with event toggles](/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-1.png) + +9. Select the application from the dropdown. + +![FastEdge apps section with On request headers enabled and application dropdown](/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-2.png) + +10. (Optional) Select the **Interrupt request processing in case of error** checkbox. + +![Add option dialog showing FastEdge apps section](/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/rule-options-fastedge-app-enable.png) + + +The **Interrupt request processing in case of error** checkbox is enabled by default. When active, errors on the FastEdge side return the relevant response code to the client. When disabled, the CDN ignores the error and forwards the request to the origin. + + +11. Click **Create rule**. + +
+
+ +## Disconnect FastEdge from CDN + +

To stop FastEdge processing on a CDN resource, disable the configured toggles and save.

+ +1. In the Customer Portal, navigate to **CDN**. +2. Find the resource and open its settings. + +![CDN resources list with resource settings button](/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-resource-settings-button.png) + +3. To disable FastEdge for the **whole CDN resource**, disable the toggles in the **FastEdge apps** section. +4. To disable FastEdge for **specific URL paths**, open the **Rules** page and disable the toggle for the relevant rule. +5. Click **Save changes**. + +## Delete a CDN application + + +An enabled FastEdge application linked to a CDN resource cannot be deleted. Disconnect it from the CDN resource first. + + +1. In the Customer Portal, navigate to **FastEdge**. +2. Open the **CDN Applications** page and click the three-dot icon next to the application. + +![CDN Applications list with three-dot menu open showing Delete option](/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/remove-app-fstedge.png) + +3. Click **Delete**. +4. Confirm by clicking **Yes, delete**. + +![Delete app confirmation dialog](/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/confirm-deletion.png) + +
+ + +FastEdge CDN applications run inside the CDN request pipeline and modify requests and responses before they reach the origin or client. + +A CDN resource configured for the origin is required. To create one, use the [Create CDN resource](/api-reference/cdn/cdn-resources/create-cdn-resource) API endpoint. + +

All requests authenticate with an [API token](/account-settings/api-tokens). Set it as an environment variable before running the examples:

+ +```bash +export GCORE_API_KEY="{YOUR_API_KEY}" +``` + +## How it works + +The CDN runtime invokes a CDN application at five stages of the request lifecycle: + +- **on_request_headers:** when the CDN receives request headers, before cache. +- **on_request_headers_after_cache:** when the CDN receives request headers, after cache. +- **on_request_body:** when the CDN receives the request body. +- **on_response_headers:** before the CDN sends response headers to the client. +- **on_response_body:** before the CDN sends the response body to the client. + +CDN applications are built on the [Proxy-Wasm](https://github.com/proxy-wasm/spec) specification — an open standard for WebAssembly-based proxy extensions. + +Only one FastEdge application can be attached to each processing stage. + +## Step 1. Upload a binary + + +

Upload the compiled `.wasm` file to the FastEdge binary store. The API automatically detects the binary type from the file contents.

+ +```bash +curl -X POST https://api.gcore.com/fastedge/v1/binaries/raw \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/octet-stream" \ + --data-binary @app.wasm +``` + +

The response includes the binary ID used in the next step:

+ +```json +{ + "id": 12345, + "api_type": "proxy-wasm" +} +``` + +

To deploy from the predefined JWT template instead, list available templates with GET https://api.gcore.com/fastedge/v1/template, note the template's `binary` field, and use that binary ID in Step 2.

+ +## Step 2. Create a FastEdge application + +

Create the application using the binary ID from Step 1. Set `status` to `1` to activate the application immediately.

+ +```bash +curl -X POST https://api.gcore.com/fastedge/v1/apps \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "my-cdn-app", + "binary": 12345, + "status": 1, + "env": { + "MY_VARIABLE": "value" + } + }' +``` + +

The response includes the application ID (`id`), which is needed to configure the CDN resource:

+ +```json +{ + "id": 67890, + "name": "my-cdn-app", + "status": 1, + "api_type": "proxy-wasm" +} +``` + +## Step 3. Enable FastEdge for your CDN resource + +

Update the CDN resource to route traffic through the FastEdge application. The `fastedge` option accepts five trigger stages — configure the ones the application handles.

+ +```bash +curl -X PATCH https://api.gcore.com/cdn/resources/RESOURCE_ID \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "options": { + "fastedge": { + "enabled": true, + "on_request_headers": { + "app_id": "67890", + "enabled": true, + "interrupt_on_error": true + } + } + } + }' +``` + +

Replace `RESOURCE_ID` with the CDN resource ID. The `interrupt_on_error` field controls behavior on error: `true` returns the FastEdge error to the client, `false` forwards the request to the origin. For security-sensitive applications, set it to `true`.

+ +

To apply FastEdge only to specific URL paths, create a CDN rule with POST https://api.gcore.com/cdn/resources/RESOURCE_ID/rules and include the `fastedge` option in the rule's `options` object.

+ +## Disable FastEdge integration + +

Set `fastedge.enabled` to `false` to stop FastEdge processing on a CDN resource:

+ +```bash +curl -X PATCH https://api.gcore.com/cdn/resources/RESOURCE_ID \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "options": { + "fastedge": { + "enabled": false + } + } + }' +``` + +## Delete a CDN application + + +An enabled FastEdge application linked to a CDN resource cannot be deleted. Disable the FastEdge integration on the CDN resource before deleting the application. + + +```bash +curl -X DELETE https://api.gcore.com/fastedge/v1/apps/APP_ID \ + -H "Authorization: APIKey $GCORE_API_KEY" +``` + +

A `204 No Content` response confirms the application was deleted.

- +
+
diff --git a/fastedge/getting-started/setup-javascript.mdx b/fastedge/getting-started/setup-javascript.mdx new file mode 100644 index 000000000..b874bc699 --- /dev/null +++ b/fastedge/getting-started/setup-javascript.mdx @@ -0,0 +1,63 @@ +--- +title: Set up JavaScript for FastEdge +sidebarTitle: JavaScript +ai-navigation: Set up the FastEdge JavaScript SDK, install Node.js v22 or higher, install the fastedge-sdk-js package, configure a project, and verify the toolchain compiles a FastEdge application to WebAssembly. +--- + +The FastEdge JavaScript SDK (`@gcoredev/fastedge-sdk-js`) compiles JavaScript applications to WebAssembly so they can run on Gcore's edge network. It is the recommended way to build FastEdge applications in JavaScript. + +[Node.js](https://nodejs.org) v22 or higher is required. + +## Install the SDK + +The steps below set up a minimal project manually. To scaffold a project from a template instead, run `npm create fastedge-app` — it handles folder creation, dependency installation, and project structure interactively. + +```sh +mkdir my-app +cd my-app +npm init -y +npm install --save-dev @gcoredev/fastedge-sdk-js +``` + +`npm init -y` creates `package.json` with `"type": "commonjs"` by default. The SDK bundler requires ESM — change it before building: + +```sh +npm pkg set type=module +``` + +After installation, three CLI tools are available via `npx`: + +| Tool | Purpose | +|------|---------| +| `fastedge-build` | Compiles JavaScript to a WebAssembly binary | +| `fastedge-init` | Creates build config for repeatable builds | +| `fastedge-assets` | Packages static files for edge serving | + +## Write a handler + +FastEdge applications register a `fetch` event listener that receives an HTTP request and returns a response. Create `src/index.js`: + +```js +addEventListener('fetch', (event) => { + event.respondWith(new Response('Hello from FastEdge')); +}); +``` + +The `fetch` event model follows the [Service Worker API](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) convention. `event.respondWith()` accepts a `Response` object or a `Promise`. Under the hood, the SDK compiles to the [WASI P2](https://wasi.dev/releases/wasi-p2) `wasi:http/proxy` world — the same standard used by the Modern Rust SDK. + +## Verify the toolchain + +Compile the handler to a WebAssembly binary: + +```sh +npx fastedge-build --input src/index.js --output wasm/app.wasm +``` + +A successful build prints: + +``` +Build success!! +"src/index.js" -> "wasm/app.wasm" +``` + +The compiled binary is at `./wasm/app.wasm`. That file can be uploaded to FastEdge directly or used as the starting point for the next tutorial. diff --git a/fastedge/getting-started/setup-rust-cdn.mdx b/fastedge/getting-started/setup-rust-cdn.mdx new file mode 100644 index 000000000..4317411b4 --- /dev/null +++ b/fastedge/getting-started/setup-rust-cdn.mdx @@ -0,0 +1,94 @@ +--- +title: Set up Rust for FastEdge CDN apps +sidebarTitle: Rust (CDN / Proxy-Wasm) +ai-navigation: Set up Rust for FastEdge CDN applications using the proxy-wasm crate and wasm32-wasip1, add the WebAssembly target, configure Cargo.toml, and verify the toolchain compiles a CDN filter. +--- + +FastEdge CDN applications run inside Gcore's CDN pipeline and can intercept HTTP traffic at four stages: on request headers, on request body, on response headers, and on response body. They are built on the [Proxy-Wasm](https://github.com/proxy-wasm/spec) specification — an open standard for WebAssembly-based proxy extensions used across CDN and service mesh environments. + +In Rust, Proxy-Wasm applications use the `proxy-wasm` crate. Instead of a single request handler, a CDN application implements callbacks such as `on_http_request_headers` and `on_http_response_headers`, which the CDN runtime invokes at different stages of request processing. + +[Rust and Cargo](https://rustup.rs) are required. On Windows, also install [Visual Studio Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022) with the **Desktop development with C++** workload. + +## Add the WebAssembly target + +CDN apps compile to `wasm32-wasip1`. Add the target once — it applies to all future builds: + +```sh +rustup target add wasm32-wasip1 +``` + +If the [Legacy Rust SDK](/fastedge/getting-started/setup-rust-legacy) is already set up, this target is already present. + +## Configure a project + +FastEdge applications compile to WebAssembly libraries. Two changes from the Cargo defaults are needed: the output type must be `cdylib`, and `proxy-wasm` must be listed as a dependency. + +1. Create the library crate: + + ```sh + cargo new --lib my-cdn-app + cd my-cdn-app + ``` + +2. Replace the contents of `Cargo.toml`: + + ```toml + [package] + name = "my_cdn_app" + version = "0.1.0" + edition = "2021" + + [lib] + crate-type = ["cdylib"] + + [dependencies] + proxy-wasm = "0.2" + log = "0.4" + ``` + + `proxy-wasm = "0.2"` provides the filter traits and the `proxy_wasm::main!` entry point. `log` is used for structured logging inside the CDN pipeline. + +## Verify the toolchain + +A minimal filter that adds a custom request header is enough to confirm the toolchain produces a valid CDN binary. Replace `src/lib.rs`: + +```rust +use proxy_wasm::traits::*; +use proxy_wasm::types::*; + +proxy_wasm::main! {{ + proxy_wasm::set_log_level(LogLevel::Trace); + proxy_wasm::set_root_context(|_| -> Box { + Box::new(MyRoot) + }); +}} + +struct MyRoot; +impl Context for MyRoot {} +impl RootContext for MyRoot { + fn create_http_context(&self, _: u32) -> Option> { + Some(Box::new(MyFilter)) + } + fn get_type(&self) -> Option { + Some(ContextType::HttpContext) + } +} + +struct MyFilter; +impl Context for MyFilter {} +impl HttpContext for MyFilter { + fn on_http_request_headers(&mut self, _: usize, _: bool) -> Action { + self.add_http_request_header("x-fastedge", "cdn"); + Action::Continue + } +} +``` + +Build it: + +```sh +cargo build --release --target wasm32-wasip1 +``` + +The first build downloads dependencies and takes one to two minutes. When it completes without errors, the toolchain is ready — the compiled binary is at `./target/wasm32-wasip1/release/my_cdn_app.wasm`. That file can be uploaded to FastEdge as a CDN application. diff --git a/fastedge/getting-started/setup-rust-legacy.mdx b/fastedge/getting-started/setup-rust-legacy.mdx new file mode 100644 index 000000000..ef3cc6680 --- /dev/null +++ b/fastedge/getting-started/setup-rust-legacy.mdx @@ -0,0 +1,76 @@ +--- +title: Set up Rust for FastEdge +sidebarTitle: Rust (Legacy HTTP) +ai-navigation: Set up the FastEdge Legacy Rust SDK using the fastedge crate and wasm32-wasip1, add the WebAssembly target, configure Cargo.toml, and verify the toolchain compiles a FastEdge application. +--- + +The Legacy Rust SDK is based on the `fastedge` crate, Gcore's original Rust library for FastEdge HTTP applications. Most existing FastEdge applications written in Rust use this SDK. Use this setup when working with existing applications built on the `fastedge` crate or when maintaining code that still targets `wasm32-wasip1`. + +The crate provides the `#[fastedge::http]` entry-point macro together with APIs for environment variables, secrets, key-value storage, dictionary access, and cache integration. + +[Rust and Cargo](https://rustup.rs) are required. On Windows, also install [Visual Studio Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022) with the **Desktop development with C++** workload. + + +For new applications, the [Modern Rust SDK](/fastedge/getting-started/setup-rust-modern) (`wstd`, `wasm32-wasip2`) is the recommended direction — it uses the WASI-HTTP standard and reduces dependency on Gcore-specific tooling. + + +## Add the WebAssembly target + +The Legacy SDK compiles to `wasm32-wasip1`. Add the target once — it applies to all future builds: + +```sh +rustup target add wasm32-wasip1 +``` + +## Configure a project + +FastEdge applications compile to WebAssembly libraries rather than standalone executables. Two changes from the Cargo defaults are needed: the output type must be `cdylib`, and the `fastedge` crate must be listed as a dependency. + +1. Create the library crate: + + ```sh + cargo new --lib my-app + cd my-app + ``` + +2. Replace the contents of `Cargo.toml`: + + ```toml + [package] + name = "my_app" + version = "0.1.0" + edition = "2021" + + [lib] + crate-type = ["cdylib"] + + [dependencies] + fastedge = "0.4" + anyhow = "1.0" + ``` + + `crate-type = ["cdylib"]` changes the output to a format the FastEdge runtime can load. `fastedge = "0.4"` provides the entry-point macro and access to FastEdge-specific APIs. `anyhow` is used for error handling in the verification example below. + +## Verify the toolchain + +A minimal handler is enough to confirm the toolchain produces a valid WebAssembly binary. Replace `src/lib.rs`: + +```rust +use fastedge::body::Body; +use fastedge::http::{Request, Response, StatusCode, Error}; + +#[fastedge::http] +fn main(_req: Request) -> Result, Error> { + Response::builder() + .status(StatusCode::OK) + .body(Body::from("OK")) +} +``` + +Build it: + +```sh +cargo build --release --target wasm32-wasip1 +``` + +The first build downloads dependencies and takes one to two minutes. When it completes without errors, the toolchain is ready — the compiled binary is at `./target/wasm32-wasip1/release/my_app.wasm`. That file can be uploaded to FastEdge directly or used as the starting point for the next tutorial. diff --git a/fastedge/getting-started/setup-rust-modern.mdx b/fastedge/getting-started/setup-rust-modern.mdx new file mode 100644 index 000000000..1d86b08b3 --- /dev/null +++ b/fastedge/getting-started/setup-rust-modern.mdx @@ -0,0 +1,74 @@ +--- +title: Set up Rust for FastEdge +sidebarTitle: Rust (Modern HTTP) +ai-navigation: Set up Rust for FastEdge HTTP applications using wstd and wasm32-wasip2, add the WebAssembly target, configure Cargo.toml with the wstd dependency, and verify the toolchain compiles successfully. +--- + +The Modern Rust SDK is the recommended approach for new FastEdge HTTP applications. It is based on [WASI-HTTP](https://github.com/WebAssembly/WASI), the standard WebAssembly interface for HTTP applications, and uses the `wstd` crate, which provides Rust bindings for WASI-HTTP. + +[Rust and Cargo](https://rustup.rs) are required. On Windows, also install [Visual Studio Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022) with the **Desktop development with C++** workload. + + +Existing apps built with the `fastedge` crate and `wasm32-wasip1` use a different setup — covered in the [Legacy Rust](/fastedge/getting-started/setup-rust-legacy) guide. + + +## Add the WebAssembly target + +FastEdge runs applications compiled to `wasm32-wasip2`. Add the target once — it applies to all future builds: + +```sh +rustup target add wasm32-wasip2 +``` + +## Configure a project + +FastEdge applications compile to WebAssembly libraries rather than standalone executables, so start with a Rust library project. Two changes from the defaults are needed: the output type must be `cdylib` (a format the WASI runtime can load), and `wstd` must be listed as a dependency. + +1. Create the library crate: + + ```sh + cargo new --lib my-app + cd my-app + ``` + +2. Replace the contents of `Cargo.toml`: + + ```toml + [package] + name = "my_app" + version = "0.1.0" + edition = "2021" + + [lib] + crate-type = ["cdylib"] + + [dependencies] + wstd = "0.6" + anyhow = "1" + ``` + + Without `crate-type = ["cdylib"]`, the build succeeds but the output can't run as a FastEdge application. + +## Verify the toolchain + +A minimal handler is enough to confirm the toolchain produces a valid WebAssembly component. Replace `src/lib.rs`: + +```rust +use wstd::http::body::Body; +use wstd::http::{Request, Response}; + +#[wstd::http_server] +async fn main(_request: Request) -> anyhow::Result> { + Ok(Response::builder() + .status(200) + .body(Body::from("OK"))?) +} +``` + +Build it: + +```sh +cargo build --release --target wasm32-wasip2 +``` + +The first build downloads dependencies and takes one to two minutes. When it completes without errors, the toolchain is ready — the compiled binary is at `./target/wasm32-wasip2/release/my_app.wasm`. diff --git a/fastedge/kv-stores/bloom-filter.mdx b/fastedge/kv-stores/bloom-filter.mdx index 725b68caf..2f32af2f9 100644 --- a/fastedge/kv-stores/bloom-filter.mdx +++ b/fastedge/kv-stores/bloom-filter.mdx @@ -1,89 +1,188 @@ --- title: Bloom Filter sidebarTitle: Bloom Filter -ai-navigation: Create and manage Bloom Filters in FastEdge Edge Storage via Gcore Customer Portal to test set membership with space-efficient probabilistic data structures supporting manual value entry and file uploads up to 1 MB. +ai-navigation: Create and manage Bloom Filters in FastEdge Edge Storage via the Gcore Customer Portal or the FastEdge REST API. Bloom filters are space-efficient probabilistic structures that test set membership and support only append operations — individual values cannot be removed once added. --- -### What is a Bloom Filter? +import { MethodSwitch, MethodSection } from "/snippets/method-switch.jsx"; -A Bloom Filter is a space-efficient probabilistic data structure used to test whether an element is a member of a set. It can yield false positives but never false negatives, meaning it may indicate that an element is in the set when it is not, but if it indicates that an element is not in the set, it definitely is not. + + -Bloom Filters are particularly useful in scenarios where space is a constraint and where the cost of false positives is low. They are commonly used in applications such as database query optimization, network caching, and distributed systems to quickly check for membership without storing the entire dataset. +

Bloom Filters are designed for fast membership checks on large datasets. Common use cases include IP blocklists, bot detection, deduplication, and cache pre-screening.

-- False positives are possible, but false negatives are not. -- The size of the Bloom Filter and the number of hash functions used affect its performance and accuracy. -- Once an element is added to a Bloom Filter, it cannot be removed. +

Unlike a regular key-value store, applications do not use Bloom Filters to retrieve stored values. Instead, they answer one question: "Have I seen this value before?" Bloom Filters can return false positives — reporting a value as present when it is not — but never false negatives. Once a value is added, it cannot be removed individually.

+## Create a Bloom Filter -## Creating a Bloom Filter +

Open the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge**, and select **Edge Storage** in the sidebar. Click the store name to open it.

-1\. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge** and choose the relevant page: **Edge Storage**. - -2\. Find the Edge Storage you want to edit and click its name to open it. - -3\. Click **Insert item** and select **Bloom Filter**. +1. Click **Insert item** and select **Bloom Filter**. - ![FastEdge Insert Bloom - Filter](/images/docs/fastedge/kv-stores/bloom-filter/insert-bloom.png) + ![Edge Storage store view with Insert item dropdown showing Bloom Filter option](/images/docs/fastedge/kv-stores/bloom-filter/insert-bloom.png) -4\. Give the Bloom Filter a key, then click **Insert value** +2. Enter a key in the **Key** field. - ![FastEdge Create Bloom - Filter](/images/docs/fastedge/kv-stores/bloom-filter/create-bloom.png) + ![Create Bloom Filter form with Key field and empty values table](/images/docs/fastedge/kv-stores/bloom-filter/create-bloom.png) -5\. Add as many rows as you would like, providing the value. Values can be entered manually or uploaded from file. +3. Click **Insert value**. In the panel that opens, enter a value in the **Value** field. - ![FastEdge Insert Bloom Filter - Values](/images/docs/fastedge/kv-stores/bloom-filter/insert-bloom-values.png) + ![Insert Bloom Filter values panel with Value fields and Add value button](/images/docs/fastedge/kv-stores/bloom-filter/insert-bloom-values.png) -Click **+ Add value** to get another entry row. - - -**Info** - -Uploading values from file has a 1 MB file size limit. +4. To add more values, click **+ Add value** and fill in the field. -**Note**: -File uploads will transform the value in the UI Portal to a hash representation of its content. +5. Click **Save** to create the Bloom Filter. + +Uploading a value from a file has a 1 MB size limit. File uploads replace the value in the portal with a hash of the file content. -## Editing a Bloom Filter +## Edit a Bloom Filter -1\. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge** and choose the relevant page: **Edge Storage**. - -2\. Find the Edge Storage you want to edit and click its name to open it. - -3\. Find the Bloom Filter you want to edit, click the three-dot icon next to the key-value and select **Edit**. +

To edit a Bloom Filter, open the store that contains it. In the item list, click the three-dot icon next to the Bloom Filter and select **Edit**.

- ![FastEdge Edge Bloom Filter - Edit](/images/docs/fastedge/kv-stores/bloom-filter/edit-bloom-store.png) + ![Edge Storage store view with three-dot menu open on a Bloom Filter row showing Edit and Delete options](/images/docs/fastedge/kv-stores/bloom-filter/edit-bloom-store.png) -4\. You are now able to add more values. Editing existing values or deleting values is not available. +

The editor lists the current values and a search box. Click **Insert value** to open the value panel, add entries, and click **Save Bloom Filter** to apply.

- ![FastEdge Edge Bloom Filter - Editting](/images/docs/fastedge/kv-stores/bloom-filter/edit-bloom-filter.png) + ![Edit Bloom Filter page showing existing values list and Insert value button](/images/docs/fastedge/kv-stores/bloom-filter/edit-bloom-filter.png) -The probabilistic nature of this data structure prevents you from changing existing values. + +Bloom Filters are append-only. Individual values cannot be edited or removed. To reset the filter, delete it and create a new one. + -5\. If everything is configured correctly, click **Save Bloom Filter** in the top right corner. +## Delete a Bloom Filter -## Deleting a Bloom Filter +

To delete a Bloom Filter, open the store that contains it. Click the three-dot icon next to the Bloom Filter and select **Delete**. Confirm the deletion when prompted.

-1\. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge** and choose the relevant page: **Edge Storage**. +
+ -2\. Find the Edge Storage you want to edit and click its name to open it. +

Bloom Filters are managed through the same data endpoint as key-value pairs. Use datatype: bloom_filter in all operations.

-3\. Find the Bloom Filter you want to delete, click the three-dot icon next to the Bloom Filter and select **Delete**. + +An [API token](/account-settings/api-tokens) is required. Use the store ID from the store creation response or from the list endpoint. + -4\. Confirm you want to delete the entire Bloom Filter. +```bash +export GCORE_API_KEY="{YOUR_API_KEY}" +export STORE_ID="{YOUR_STORE_ID}" +``` + +## Create a Bloom Filter + +

A Bloom Filter is stored as a single key inside an Edge Storage store. The key identifies the filter, while the payload contains its values.

+ +

Use PUT /fastedge/v1/kv/{store_id}/data with op: add to create a Bloom Filter. The payload is an array of values, each with an encoding and a value field.

+ +```bash +curl -X PUT "https://api.gcore.com/fastedge/v1/kv/$STORE_ID/data" \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '[ + { + "op": "add", + "key": "blocked-ips", + "datatype": "bloom_filter", + "payload": [ + { "encoding": "plain", "value": "192.168.1.1" }, + { "encoding": "plain", "value": "10.0.0.1" }, + { "encoding": "plain", "value": "172.16.0.5" } + ] + } + ]' +``` + +

The API returns write statistics:

+ +```json +{ + "write_count": 3, + "del_count": 0, + "write_size": 71, + "store_size": 356, + "revision": 602 +} +``` + +## Read a Bloom Filter + +

The API exposes the stored values for management and debugging purposes. Applications typically use Bloom Filters for membership checks rather than value retrieval.

+ +

Retrieve the values stored in a Bloom Filter with GET /fastedge/v1/kv/{store_id}/data/{key}:

+ +```bash +curl "https://api.gcore.com/fastedge/v1/kv/$STORE_ID/data/blocked-ips" \ + -H "Authorization: APIKey $GCORE_API_KEY" +``` + +

The API returns the full value list:

+ +```json +{ + "datatype": "bloom_filter", + "key": "blocked-ips", + "payload": [ + { "encoding": "plain", "value": "192.168.1.1" }, + { "encoding": "plain", "value": "10.0.0.1" }, + { "encoding": "plain", "value": "172.16.0.5" } + ], + "count": 3 +} +``` + +## Add values + +

Unlike sorted sets, Bloom Filters do not support updates or removals. New values can only be appended. Use the same PUT endpoint with op: add to add values to an existing filter. Values that are already present are ignored without error.

+ +```bash +curl -X PUT "https://api.gcore.com/fastedge/v1/kv/$STORE_ID/data" \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '[ + { + "op": "add", + "key": "blocked-ips", + "datatype": "bloom_filter", + "payload": [ + { "encoding": "plain", "value": "192.168.2.100" } + ] + } + ]' +``` + + +del_entries is not supported for Bloom Filters. Removing individual values would introduce false negatives and break the fundamental guarantee of the data structure — Bloom Filters are append-only by design. To reset a filter, delete it with op: del_key and recreate it. + + +## Delete a Bloom Filter + +

Use op: del_key to delete the entire Bloom Filter and all its values.

+ +```bash +curl -X PUT "https://api.gcore.com/fastedge/v1/kv/$STORE_ID/data" \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '[ + { + "op": "del_key", + "key": "blocked-ips", + "datatype": "bloom_filter" + } + ]' +``` + +

The API returns del_count: 1 on success.

+ +
+
diff --git a/fastedge/kv-stores/how-it-works.mdx b/fastedge/kv-stores/how-it-works.mdx index edce570a4..142190258 100644 --- a/fastedge/kv-stores/how-it-works.mdx +++ b/fastedge/kv-stores/how-it-works.mdx @@ -1,44 +1,31 @@ --- title: How it works sidebarTitle: How it works -ai-navigation: Deploy Edge Storage as a distributed key-value store co-located with FastEdge WASM applications at every global edge location, providing sub-millisecond read latency with write-once replication to central SQL database and eventual consistency propagation within 1-2 seconds. +ai-navigation: Understand how Edge Storage co-locates a key-value store with FastEdge applications at every edge location for sub-millisecond reads, with writes persisted via REST API to a central database and replicated globally within 1-2 seconds. --- -Edge Storage leverages a distributed key-value store architecture optimized for FastEdge's global WASM runtime. Here's what makes it unique: +Edge Storage is a globally replicated key-value store for FastEdge applications. A local replica is available at every edge location where the application runs, allowing reads to be served directly from the edge node handling the request. -### Architecture +Unlike CDN solutions that place data stores at regional POP locations, Edge Storage deploys a replica at every FastEdge location. -**Co-located storage instances**: Unlike traditional CDN solutions that run data stores at regional Point-of-Presence (POP) locations, Edge Storage deploys a storage instance at every edge location where your FastEdge application runs. This means your WASM component and its data store exist in the same environment, eliminating network hops and providing single-digit millisecond read latency. +## Architecture -**Write-once, replicate everywhere**: When you write data through the API, it's first persisted to a central SQL database, then automatically replicated to all edge storage instances globally. This replication typically completes within 1-2 seconds. +Edge Storage is deployed next to FastEdge applications at every edge location. When an application reads from a store, it reads from the local replica on the same edge node — no network call to a regional or central database is needed. -### Performance characteristics +Writes follow a different path. They are sent through the REST API, persisted in a central SQL database, and then replicated to all edge locations globally. Replication typically completes within 1–2 seconds. This makes Edge Storage well-suited for data that is read frequently but written infrequently: configuration, feature flags, lookup tables, blocklists, and similar reference data. -- **Ultra-fast reads**: Reading from Edge Storage happens locally at each edge with sub-millisecond latency since the data store runs alongside your WASM application -- **Eventual consistency for writes**: API writes take 1-2 seconds to propagate globally, making Edge Storage ideal for read-heavy workloads +## Edge Storage vs Cache -### Why this approach wins - -Traditional edge computing platforms place data stores at regional POP locations, forcing your application to make network calls to reach the data store. This introduces latency and potential failure points. By co-locating the storage with your WASM runtime at every edge, Edge Storage delivers: - -- **Lower latency**: No network round-trips between your application and data store -- **Higher reliability**: Data access doesn't depend on cross-datacenter connectivity -- **Better performance**: Optimize for the 99% use case (reads) while accepting slightly slower writes - -This architecture is perfect for frequently-read, infrequently-written data. Ideal use cases include configuration data, feature flags, content fragments, and blocklist/allowlist checks based on IP addresses, IP subnets, ASNs, and similar criteria. - -## When to use Edge Storage vs Cache - -Edge Storage and [Cache](/fastedge/cache) solve different problems. Edge Storage is the right choice when you need durable, globally consistent data that is created and managed ahead of time. Cache is the right choice when you need fast, POP-local state at runtime — for example, counters or memoized values that do not need to be shared between POPs. +Edge Storage and [Cache](/fastedge/cache) address different requirements. Edge Storage is the right choice for durable, globally consistent data created and managed ahead of time. Cache is the right choice for fast, POP-local state at runtime — for example, counters or memoized values that do not need to be shared between POPs. | | Edge Storage (KV) | Cache | |---|---|---| | Scope | Globally replicated to all POPs | Single POP | | Consistency | Eventual (1–2 seconds globally) | Strong (within a POP) | | Durability | Durable, backed by a central database | Transient, evictable | -| Provisioning | Created in the Customer Portal and linked to your application | None — available at runtime on paid plans | +| Provisioning | Created in the portal and linked to the application | None — available at runtime on paid plans | | Writes from the API | Yes | No (runtime only) | | Atomic counters | No | Yes (`incr`; `decr` JS only) | | Typical workloads | Configuration, feature flags, lookup tables, blocklists, sorted sets, Bloom filters | Rate limits, response memoization, idempotency keys, per-request deduplication | -The two can be used together: store the source of truth in Edge Storage and use Cache to memoize derived results or to enforce per-POP rate limits. +The two can be used together: store the source of truth in Edge Storage and use Cache to memoize derived results or enforce per-POP rate limits. diff --git a/fastedge/kv-stores/manage-kv-store.mdx b/fastedge/kv-stores/manage-kv-store.mdx index a88be08ce..197441f4a 100644 --- a/fastedge/kv-stores/manage-kv-store.mdx +++ b/fastedge/kv-stores/manage-kv-store.mdx @@ -9,9 +9,11 @@ import { MethodSwitch, MethodSection } from "/snippets/method-switch.jsx"; -Edge Storage holds key-value data on Gcore's global edge network and makes it available to FastEdge applications at low latency. Data is replicated across edge locations, so reads are served locally to each request regardless of where in the world it originates. +Edge Storage stores key-value data that FastEdge applications can read at runtime. -

Each store is a named container for key-value pairs. After creation, a store must be linked to a FastEdge application before the application can access it — linking instructions are in [Managing applications](/fastedge/manage-apps#edge-storage).

+

Each store is a named container for key-value pairs. After creating a store, link it to a FastEdge application before the application can access its data — linking instructions are in [Managing applications](/fastedge/manage-apps#edge-storage).

+ +

Data is replicated across Gcore's edge network, so reads are served from a local copy at the edge location handling each request.

## Create a store @@ -41,12 +43,14 @@ Edge Storage holds key-value data on Gcore's global edge network and makes it av ## Insert key-value pairs -

Key-value pairs can be entered manually, loaded from a file, or set with an expiration date. Pairs can be added during the creation wizard (step 2) or at any time by clicking the store name in the Edge Storage list to open it.

+

Key-value pairs are added through the **Insert item** panel inside the store view. Pairs can be added during the creation wizard (step 2) or at any time by clicking the store name in the Edge Storage list to open it.

### Add a pair manually

Click **Insert item** and select **KV pair**. In the panel that opens, enter the key and value. Click **+ Add value** to add another row. Click **Save** to apply the changes.

+

Keys are limited to 256 bytes.

+ ![Insert item dropdown with KV pair selected](/images/docs/fastedge/kv-stores/manage-kv-store/insert-pair.png) @@ -55,39 +59,37 @@ Edge Storage holds key-value data on Gcore's global edge network and makes it av ![Side panel with key-value input rows](/images/docs/fastedge/kv-stores/manage-kv-store/first-pair.png) -

The panel also provides two additional options for each value in the same row:

- -- **Upload from file** — click the upload icon to load the value from a file instead of typing it. Text and binary files are supported — images, fonts, and similar assets. The maximum file size is 1 MB. After uploading, the portal displays a hash of the file content rather than the original filename. -- **Set expiration** — click the expiry icon to assign a date and time after which the value stops being returned to applications. It may remain visible in the portal briefly after expiration. +### Upload a value from a file -

Keys are limited to 256 bytes.

+

To load a value from a file instead of typing it, click the upload icon in the value row. Text and binary files are supported — images, fonts, and similar assets. The maximum file size is 1 MB. After uploading, the portal displays a hash of the file content rather than the original filename.

![Upload icon in the key-value pair row](/images/docs/fastedge/kv-stores/manage-kv-store/upload-pair.png) +### Set an expiration date + +

To assign an expiration to a value, click the expiry icon in the value row and select a date and time. After that point, the value stops being returned to applications. It may remain visible in the portal briefly after expiration.

+ ![Expiry icon in the key-value pair row](/images/docs/fastedge/kv-stores/manage-kv-store/expire-pair.png) ## Edit a key-value pair -

Clicking a store name in the Edge Storage list opens the **Edit Edge Storage** page where all pairs are listed. To edit a pair, click the three-dot icon next to it, select **Edit**, update the value or expiration date, then click **Save**.

+

Once pairs are in a store, individual values can be updated at any time. Clicking a store name in the Edge Storage list opens the **Edit Edge Storage** page where all pairs are listed. To edit a pair, click the three-dot icon next to it, select **Edit**, update the value or expiration date, then click **Save**.

![Three-dot menu with Edit option highlighted](/images/docs/fastedge/kv-stores/manage-kv-store/edit-store.png) -**Info** - Additional pairs can be inserted from the edit view. Submitting a key that already exists in the store overwrites its current value. - ## Delete key-value pairs -

Individual and bulk deletion are both available from inside the store view.

+

To remove outdated or incorrect data, pairs can be deleted individually or in bulk. Open the store by clicking its name in the Edge Storage list to access both options.

To delete a single pair, click the three-dot icon next to it, select **Delete**, and confirm.

@@ -105,7 +107,11 @@ Additional pairs can be inserted from the edit view. Submitting a key that alrea

The external store must be publicly accessible. Gcore's edge nodes connect to it over the network on each request.

-

**Hosted Edge Storage vs BYOD.** With hosted Edge Storage, data lives at every edge location globally and reads are served locally — latency is typically in the single-digit milliseconds. With BYOD, each read is a live query to the external database, so response time depends on the network distance between the edge location and the database host. BYOD is a practical choice for development, testing, or workloads where read speed is not critical. For latency-sensitive production workloads, hosted Edge Storage is recommended.

+## Hosted Edge Storage vs BYOD + +

With hosted Edge Storage, data lives at every edge location globally and reads are served locally — latency is typically in the single-digit milliseconds. With BYOD, each read is a live query to the external database, so response time depends on the network distance between the edge location and the database host.

+ +

BYOD is a practical choice for development, testing, or workloads where read speed is not critical. For latency-sensitive production workloads, hosted Edge Storage is recommended.

Supported URL schemes:

@@ -114,7 +120,7 @@ Additional pairs can be inserted from the edit view. Submitting a key that alrea

URL format: `redis://:password@host:port/db-index` or `redis://username:password@host:port/db-index`

-### Create a BYOD store +## Create a BYOD store

Follow steps 1–3 from [Create a store](#create-a-store), then:

@@ -130,20 +136,14 @@ Additional pairs can be inserted from the edit view. Submitting a key that alrea 5. Click **Create Edge Storage** to validate the connection and create the store. -**Info** - Gcore validates the connection to the external store when clicking **Create Edge Storage**. If the connection cannot be established — for example, because the host is unreachable, the port is blocked, or the credentials are wrong — the store is not created and an error message is displayed. Verify that the store is publicly accessible and the URL is correct, then try again. - -**Warning** - A store cannot be converted between BYOD and hosted storage after creation. The store type is permanent. - -### Link a BYOD store to an application +## Link a BYOD store to an application

After creation, link the BYOD store to a FastEdge application using the same process as a regular store — instructions are in [Managing applications](/fastedge/manage-apps#edge-storage). Once linked, the application accesses the BYOD store through the standard SDK API. The prefix is applied transparently and the application code does not need to know whether the store is BYOD or hosted.

@@ -153,7 +153,7 @@ A store cannot be converted between BYOD and hosted storage after creation. The

Automate KV store management using the [Python SDK](/developer-tools/sdks/python) or [Go SDK](/developer-tools/sdks/go) for store-level operations, while key-value data operations require direct HTTP calls to the FastEdge REST API.

-A permanent [API token](/account-settings/api-tokens) is required. Retrieve the store ID from the response when creating a store or from the list endpoint. +An [API token](/account-settings/api-tokens) is required. Retrieve the store ID from the response when creating a store or from the list endpoint. ```bash diff --git a/fastedge/kv-stores/sorted-set.mdx b/fastedge/kv-stores/sorted-set.mdx index f00972ed8..2e810c38f 100644 --- a/fastedge/kv-stores/sorted-set.mdx +++ b/fastedge/kv-stores/sorted-set.mdx @@ -1,80 +1,196 @@ --- title: Sorted Set sidebarTitle: Sorted Set -ai-navigation: Create and manage Sorted Sets (ZSET) in FastEdge Edge Storage via the Gcore Customer Portal, adding members with numeric scores that are automatically ordered for leaderboards and priority-based lists. +ai-navigation: Create and manage Sorted Sets (ZSET) in FastEdge Edge Storage via the Gcore Customer Portal or the FastEdge REST API. Sorted sets store unique members with numeric scores ordered for leaderboards, rankings, and priority-based lists. --- -### What is a Sorted Set? +import { MethodSwitch, MethodSection } from "/snippets/method-switch.jsx"; -A Sorted Set (ZSET) stores unique members, each associated with a numeric score. Members are ordered by score, which makes ZSETs ideal for leaderboards, rankings, and time- or priority-based lists. + + -You can add, update, or remove members while keeping the order automatically maintained. +

A Sorted Set (ZSET) stores unique members, each with a numeric score. Members are ordered by score, making sorted sets ideal for leaderboards, rankings, and priority-based lists. Adding the same member value again updates its score; ties in score are broken lexicographically.

-- Each member is unique; adding the same member updates its score. -- Scores are numeric; members are ordered by score, then lexicographically for ties. -- Membership is stored in-memory with scores, so very large sets can impact memory usage. +## Create a sorted set +

Open the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge**, and select **Edge Storage** in the sidebar. Click the store name to open it.

-## Creating a Sorted Set - -1\. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge** and choose the relevant page: **Edge Storage**. - -2\. Find the Edge Storage you want to edit and click its name to open it. - -3\. Click **Insert item** and select **Sorted Set**. +1. Click **Insert item** and select **Sorted Set**. - ![FastEdge Insert Sorted Set](/images/docs/fastedge/kv-stores/sorted-set/insert-zset.png) + ![Edge Storage store view with Insert item dropdown showing Sorted Set option](/images/docs/fastedge/kv-stores/sorted-set/insert-zset.png) -4\. Give the Sorted Set a key, then click **Insert value** +2. Enter a key in the **Key** field. - ![FastEdge Create Sorted Set](/images/docs/fastedge/kv-stores/sorted-set/create-zset.png) + ![Create Sorted Set form with Key field and empty values table](/images/docs/fastedge/kv-stores/sorted-set/create-zset.png) -5\. Add as many rows as you would like, providing a score and the value. Values can be entered manually or uploaded from file. +3. Click **Insert value**. In the panel that opens, enter a value in the **Value** field and a numeric score in the **Score** field. - ![FastEdge Insert Sorted Set - Values](/images/docs/fastedge/kv-stores/sorted-set/insert-zset-values.png) + ![Insert Sorted Set value panel with Value and Score fields and Add value button](/images/docs/fastedge/kv-stores/sorted-set/insert-zset-values.png) -Click **+ Add value** to get another entry row. - - -**Info** - -Uploading values from file has a 1 MB file size limit. +4. To add more members, click **+ Add value** and fill in the fields. -**Note**: -File uploads will transform the value in the UI Portal to a hash representation of its content. +5. Click **Save** to create the sorted set. + +Uploading a value from a file has a 1 MB size limit. File uploads replace the value in the portal with a hash of the file content. -## Editing a Sorted Set - -1\. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge** and choose the relevant page: **Edge Storage**. - -2\. Find the Edge Storage you want to edit and click its name to open it. +## Edit a sorted set -3\. Find the Sorted Set you want to edit, click the three-dot icon next to the key-value and select edit. +

To edit a sorted set, open the store that contains it. In the item list, click the three-dot icon next to the sorted set and select **Edit**.

- ![FastEdge Edge Sorted Set - Edit](/images/docs/fastedge/kv-stores/sorted-set/edit-zset-store.png) + ![Edge Storage store view with three-dot menu open on a sorted set row showing Edit and Delete options](/images/docs/fastedge/kv-stores/sorted-set/edit-zset-store.png) -4\. You are now able to add more values, edit existing values or delete values. +

The editor lists all current members and their scores. Add new members with **Insert value** or remove existing ones using the delete icon in each row. Click **Save Sorted Set** to apply the changes.

-5\. If everything is configured correctly, click **Save Sorted Set** in the top right corner. +## Delete a sorted set -## Deleting a Sorted Set +

To delete a sorted set, open the store that contains it. Click the three-dot icon next to the sorted set and select **Delete**. Confirm the deletion when prompted.

-1\. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge** and choose the relevant page: **Edge Storage**. +
+ -2\. Find the Edge Storage you want to edit and click its name to open it. +

Sorted sets are managed through the same data endpoint as key-value pairs. Use datatype: sorted_set in all operations.

-3\. Find the Sorted Set you want to delete, click the three-dot icon next to the Sorted Set and select delete. + +An [API token](/account-settings/api-tokens) is required. Use the store ID from the store creation response or from the list endpoint. + -4\. Confirm you want to delete the entire Sorted Set. +```bash +export GCORE_API_KEY="{YOUR_API_KEY}" +export STORE_ID="{YOUR_STORE_ID}" +``` + +## Create a sorted set + +

A sorted set is stored as a single key inside an Edge Storage store. The key identifies the set, while the payload contains its members and scores.

+ +

Use PUT /fastedge/v1/kv/{store_id}/data with op: add to create a sorted set. The payload is an array of members, each with an encoding, a value, and a numeric score.

+ +```bash +curl -X PUT "https://api.gcore.com/fastedge/v1/kv/$STORE_ID/data" \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '[ + { + "op": "add", + "key": "leaderboard", + "datatype": "sorted_set", + "payload": [ + { "encoding": "plain", "value": "player1", "score": 100 }, + { "encoding": "plain", "value": "player2", "score": 200 }, + { "encoding": "plain", "value": "player3", "score": 300 } + ] + } + ]' +``` + +

The API returns write statistics:

+ +```json +{ + "write_count": 3, + "del_count": 0, + "write_size": 78, + "store_size": 91, + "revision": 596 +} +``` + +## Read sorted set members + +

Retrieve the members of a sorted set with GET /fastedge/v1/kv/{store_id}/data/{key}:

+ +```bash +curl "https://api.gcore.com/fastedge/v1/kv/$STORE_ID/data/leaderboard" \ + -H "Authorization: APIKey $GCORE_API_KEY" +``` + +

The API returns the full member list with scores:

+ +```json +{ + "datatype": "sorted_set", + "key": "leaderboard", + "payload": [ + { "encoding": "plain", "value": "player1", "score": 100 }, + { "encoding": "plain", "value": "player2", "score": 200 }, + { "encoding": "plain", "value": "player3", "score": 300 } + ], + "count": 3 +} +``` + +

To list all entries in a store (including sorted sets), use GET /fastedge/v1/kv/{store_id}/data. Sorted sets appear with datatype: sorted_set but without member details in the list response.

+ +## Add or update members + +

Members are identified by value. If a member with the same value already exists, its score is replaced. Use the same PUT endpoint with op: add to add new members or update scores of existing ones.

+ +```bash +curl -X PUT "https://api.gcore.com/fastedge/v1/kv/$STORE_ID/data" \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '[ + { + "op": "add", + "key": "leaderboard", + "datatype": "sorted_set", + "payload": [ + { "encoding": "plain", "value": "player4", "score": 150 } + ] + } + ]' +``` + +## Remove members + +

Use op: del_entries to remove individual members while keeping the sorted set itself. Use op: del_key to remove the entire sorted set — see Delete a sorted set below.

+ +

The payload for del_entries requires only the encoding and value fields — score is not needed for deletion.

+ +```bash +curl -X PUT "https://api.gcore.com/fastedge/v1/kv/$STORE_ID/data" \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '[ + { + "op": "del_entries", + "key": "leaderboard", + "datatype": "sorted_set", + "payload": [ + { "encoding": "plain", "value": "player4" } + ] + } + ]' +``` + +

The API returns the number of deleted entries in del_count.

+ +## Delete a sorted set + +

Use op: del_key to delete the entire sorted set and all its members.

+ +```bash +curl -X PUT "https://api.gcore.com/fastedge/v1/kv/$STORE_ID/data" \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '[ + { + "op": "del_key", + "key": "leaderboard", + "datatype": "sorted_set" + } + ]' +``` + +
+
diff --git a/fastedge/llms.txt b/fastedge/llms.txt index 98d40e022..afb226fa7 100644 --- a/fastedge/llms.txt +++ b/fastedge/llms.txt @@ -1,33 +1,41 @@ # Gcore FastEdge -> Deploy WebAssembly edge applications on Gcore CDN edge nodes using FastEdge serverless compute for HTTP request processing, A/B testing, image conversion, and custom edge logic. +> FastEdge is a serverless WebAssembly edge compute platform. Run Rust and JavaScript applications at every Gcore edge location — HTTP apps, CDN extensions, edge storage, secrets, and cache available at runtime. -- [FastEdge](https://gcore.com/docs/fastedge.md): Deploy WebAssembly edge applications on Gcore CDN edge nodes using FastEdge serverless compute for HTTP request processing, A/B testing, image conversion, and custom edge logic. -- [FastEdge overview](https://gcore.com/docs/fastedge/getting-started.md): Deploy WebAssembly applications on Gcore's global edge network using FastEdge for serverless execution with HTTP request/response modification, A/B testing, personalization, image conversion, and custom DNS resolving without infrastructure maintenance. +- [FastEdge](https://gcore.com/docs/fastedge.md): FastEdge is a serverless WebAssembly edge compute platform. Run Rust and JavaScript applications at every Gcore edge location — HTTP apps, CDN extensions, edge storage, secrets, and cache available at runtime. -## Create apps -- [Create FastEdge apps](https://gcore.com/docs/fastedge/create-apps.md): Create FastEdge HTTP and CDN applications using Rust SDK, JavaScript SDK, or Proxy-Wasm spec to run serverless code on Gcore's CDN network with custom URLs and request/response processing. +## Get started +- [FastEdge overview](https://gcore.com/docs/fastedge/getting-started.md): Overview of FastEdge serverless WebAssembly execution on Gcore edge network - HTTP Applications, CDN Applications, use cases including A/B testing, personalization, authentication, and image manipulation. +- [Set up Rust for FastEdge](https://gcore.com/docs/fastedge/getting-started/setup-rust-modern.md): Set up Rust for FastEdge HTTP applications using wstd and wasm32-wasip2, add the WebAssembly target, configure Cargo.toml with the wstd dependency, and verify the toolchain compiles successfully. +- [Set up Rust for FastEdge](https://gcore.com/docs/fastedge/getting-started/setup-rust-legacy.md): Set up the FastEdge Legacy Rust SDK using the fastedge crate and wasm32-wasip1, add the WebAssembly target, configure Cargo.toml, and verify the toolchain compiles a FastEdge application. +- [Set up JavaScript for FastEdge](https://gcore.com/docs/fastedge/getting-started/setup-javascript.md): Set up the FastEdge JavaScript SDK, install Node.js v22 or higher, install the fastedge-sdk-js package, configure a project, and verify the toolchain compiles a FastEdge application to WebAssembly. +- [Set up Rust for FastEdge CDN apps](https://gcore.com/docs/fastedge/getting-started/setup-rust-cdn.md): Set up Rust for FastEdge CDN applications using the proxy-wasm crate and wasm32-wasip1, add the WebAssembly target, configure Cargo.toml, and verify the toolchain compiles a CDN filter. + +## Applications ## HTTP Applications -- [Create FastEdge HTTP applications](https://gcore.com/docs/fastedge/getting-started/create-fastedge-apps.md): Create FastEdge HTTP applications by uploading custom WebAssembly binaries built with JavaScript SDK or Rust SDK, or by deploying preconfigured templates via Gcore Customer Portal or API. -- [Built-in HTTP application templates](https://gcore.com/docs/fastedge/built-in-templates.md): Step-by-step guide for deploying FastEdge built-in HTTP application templates — Markdown renderer and Geolocation-based redirect — including environment variable configuration, real-world examples, and testing. -- [Build Rust WASI-HTTP apps](https://gcore.com/docs/fastedge/getting-started/build-a-rust-wasi-app.md): Build FastEdge Rust applications using the WASI-HTTP interface - from a hello-world component that verifies the toolchain to an app that fetches and shapes data from an external API. +- [Create FastEdge HTTP applications](https://gcore.com/docs/fastedge/getting-started/create-fastedge-apps.md): Create FastEdge HTTP applications by uploading custom WebAssembly binaries built with JavaScript SDK or Rust SDK, or by deploying preconfigured templates via Gcore Customer Portal or REST API. +- [Render Markdown at the edge](https://gcore.com/docs/fastedge/render-markdown.md): Deploy the FastEdge Markdown renderer template to fetch Markdown files from a remote URL and return them as rendered HTML pages via the Customer Portal. +- [Redirect visitors by location](https://gcore.com/docs/fastedge/geolocation-redirect.md): Deploy the FastEdge geolocation redirect template to route visitors to region-specific URLs based on their country via the Customer Portal. +- [Build a FastEdge HTTP application](https://gcore.com/docs/fastedge/getting-started/get-started-http.md): Build and deploy a FastEdge HTTP application in Modern Rust, Legacy Rust, or JavaScript via Customer Portal or REST API. +- [Call an external API from a FastEdge app](https://gcore.com/docs/fastedge/getting-started/call-external-api-rust.md): Build and deploy a FastEdge application in Modern Rust, Legacy Rust, or JavaScript that makes outbound HTTP requests, fetches data from a REST API, and returns shaped JSON via Customer Portal or REST API. ## CDN Applications -- [Extend CDN functionality with FastEdge](https://gcore.com/docs/fastedge/getting-started/integrate-cdn-with-fastedge.md): Deploy FastEdge serverless compute functions at CDN edge locations to extend content delivery with custom request/response logic, origin shielding, and dynamic content transformation. -- [CDN properties](https://gcore.com/docs/fastedge/getting-started/cdn-properties.md): Access and modify HTTP request and response properties in Gcore CDN Proxy-Wasm applications via read-write properties like path, host, queryString and read-only properties like scheme, method, country, city, ASN, latitude, longitude, region, continent deciphered from client IP. -- [Manage FastEdge apps](https://gcore.com/docs/fastedge/manage-apps.md): Manage FastEdge HTTP and CDN applications via the Customer Portal - start or stop applications, view metrics and logs, configure response headers, environment variables, secrets, and Edge Storage key-value storage. -- [Create and manage templates](https://gcore.com/docs/fastedge/create-manage-templates.md): Create FastEdge templates with custom binary files, mandatory parameters, and Secret environment variables for HTTP and CDN applications via Customer Portal. +- [Extend CDN functionality with FastEdge](https://gcore.com/docs/fastedge/getting-started/integrate-cdn-with-fastedge.md): Integrate FastEdge CDN applications with a Gcore CDN resource to add custom request and response processing via Customer Portal or REST API. +- [Build and deploy a FastEdge CDN application](https://gcore.com/docs/fastedge/getting-started/get-started-cdn.md): Build and deploy a FastEdge CDN application in Rust using Proxy-Wasm via Customer Portal or REST API. +- [Request and response properties](https://gcore.com/docs/fastedge/getting-started/cdn-properties.md): Reference for HTTP request and response properties available in FastEdge CDN Proxy-Wasm applications. Covers get_property and set_property paths, access modes per hook, and custom properties for passing state within a processing phase. +- [Manage FastEdge apps](https://gcore.com/docs/fastedge/manage-apps.md): Manage FastEdge HTTP and CDN application lifecycle, metrics, logs, and configuration via Customer Portal or REST API. +- [Create and manage templates](https://gcore.com/docs/fastedge/create-manage-templates.md): Create, edit, delete, and update FastEdge templates for HTTP and CDN applications via the Customer Portal or REST API — including binary upload, mandatory parameters, secret environment variables, and creating apps from templates. ## Secrets Manager -- [Secrets Manager](https://gcore.com/docs/fastedge/secrets-manager/manage-secrets.md): Create and manage encrypted secrets in FastEdge Secrets Manager with slot numbers and secret values, then access them in applications via JavaScript SDK and Rust SDK. -- [Secrets Slots](https://gcore.com/docs/fastedge/secrets-manager/slots.md): Configure FastEdge Secrets Slots for secret rotation by storing multiple encrypted secret versions with slot indices, enabling runtime secret updates via get_secret API without deleting old values and supporting token validation against specific secret versions using slot indices or timestamps. +- [Secrets Manager](https://gcore.com/docs/fastedge/secrets-manager/manage-secrets.md): Create, edit, and delete encrypted secrets in FastEdge Secrets Manager via the Customer Portal or REST API, then link secrets to applications that read them at runtime. +- [Secret rotation with slots](https://gcore.com/docs/fastedge/secrets-manager/slots.md): Use FastEdge Secrets Manager slots to implement secret rotation — each slot stores a separate encrypted value identified by a numeric index or Unix timestamp, enabling runtime rotation without application redeployment. ## Edge Storage -- [How it works](https://gcore.com/docs/fastedge/kv-stores/how-it-works.md): Deploy Edge Storage as a distributed key-value store co-located with FastEdge WASM applications at every global edge location, providing sub-millisecond read latency with write-once replication to central SQL database and eventual consistency propagation within 1-2 seconds. +- [How it works](https://gcore.com/docs/fastedge/kv-stores/how-it-works.md): Understand how Edge Storage co-locates a key-value store with FastEdge applications at every edge location for sub-millisecond reads, with writes persisted via REST API to a central database and replicated globally within 1-2 seconds. - [Edge Storage](https://gcore.com/docs/fastedge/kv-stores/manage-kv-store.md): Create and manage FastEdge Edge Storage stores and key-value pairs via Customer Portal or via the FastEdge REST API. -- [Sorted Set](https://gcore.com/docs/fastedge/kv-stores/sorted-set.md): Create and manage Sorted Sets (ZSET) in FastEdge Edge Storage via the Gcore Customer Portal, adding members with numeric scores that are automatically ordered for leaderboards and priority-based lists. -- [Bloom Filter](https://gcore.com/docs/fastedge/kv-stores/bloom-filter.md): Create and manage Bloom Filters in FastEdge Edge Storage via Gcore Customer Portal to test set membership with space-efficient probabilistic data structures supporting manual value entry and file uploads up to 1 MB. +- [Sorted Set](https://gcore.com/docs/fastedge/kv-stores/sorted-set.md): Create and manage Sorted Sets (ZSET) in FastEdge Edge Storage via the Gcore Customer Portal or the FastEdge REST API. Sorted sets store unique members with numeric scores ordered for leaderboards, rankings, and priority-based lists. +- [Bloom Filter](https://gcore.com/docs/fastedge/kv-stores/bloom-filter.md): Create and manage Bloom Filters in FastEdge Edge Storage via the Gcore Customer Portal or the FastEdge REST API. Bloom filters are space-efficient probabilistic structures that test set membership and support only append operations — individual values cannot be removed once added. - [Cache](https://gcore.com/docs/fastedge/cache.md): Cache is a POP-local, strongly consistent key-value store available to FastEdge applications at runtime for transient state such as rate-limit counters, response memoization, and idempotency checks. It is distinct from Edge Storage, which is globally replicated and durable. -- [Troubleshooting](https://gcore.com/docs/fastedge/troubleshooting.md): Diagnose FastEdge application failures using HTTP status codes 530 (internal error), 531 (memory limit exceeded), 532 (timeout), and 533 (crash) to identify root causes and access FastEdge SDK Rust, JavaScript, AssemblyScript, and development tools for resolution. -- [FastEdge CLI](https://gcore.com/docs/fastedge/fastedge-cli.md): Install FastEdge CLI from the FastEdge-lib repository, build the Rust-based tool, and execute local HTTP applications with commands supporting environment variables, geo headers, and request/response inspection. +- [Troubleshooting](https://gcore.com/docs/fastedge/troubleshooting.md): Diagnose FastEdge application failures using HTTP status codes 530 (initialization failed), 531 (runtime error), 532 (timeout), and 533 (memory limit exceeded). Includes debug logging via API, platform limits, and SDK-specific notes for Rust and JavaScript. +- [FastEdge CLI](https://gcore.com/docs/fastedge/fastedge-cli.md): Install fastedge-run to test FastEdge Wasm applications locally before deploying. Available as a pre-built binary for macOS, Linux, and Windows, or bundled with the FastEdge VS Code extension. Supports HTTP server mode, environment variables, and geo header simulation. diff --git a/fastedge/manage-apps.mdx b/fastedge/manage-apps.mdx index 71f35a6e6..acb653030 100644 --- a/fastedge/manage-apps.mdx +++ b/fastedge/manage-apps.mdx @@ -1,169 +1,357 @@ --- title: Manage FastEdge apps sidebarTitle: Manage FastEdge apps -ai-navigation: Manage FastEdge HTTP and CDN applications via the Customer Portal - start or stop applications, view metrics and logs, configure response headers, environment variables, secrets, and Edge Storage key-value storage. +ai-navigation: Manage FastEdge HTTP and CDN application lifecycle, metrics, logs, and configuration via Customer Portal or REST API. --- -You can view and manage your HTTP and CDN applications on the application management page: +import { MethodSwitch, MethodSection } from "/snippets/method-switch.jsx"; - - ![FastEdge applications - page](/images/docs/fastedge/manage-apps/app-management-page-annotated.png) - + + -- **Actions**: Perform quick actions, such as stopping or starting an application, editing its configuration, or deleting the application from the Customer Portal. +

The application management page provides access to all settings and runtime data for a deployed FastEdge application in one place.

-- **Template name**: If the application was created from a template, view the template and its configuration +

To open the management page:

-- **Metrics**: Check response statuses for requests to the FastEdge servers and analyze runtime duration data. +1. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge** and select either **HTTP Applications** or **CDN Applications**. -- **Logs**: View and enable application logs. +2. On the **Applications** page, click the three-dot icon next to the application and select **Manage**. -- **Response Headers**: Headers added to every response. +![HTTP Applications list with the three-dot menu open showing Stop, Manage, and Delete options](/images/docs/fastedge/manage-apps/manage-apps-menu.png) -- **Environment Variables**: Update or add environment variables. +![FastEdge application management page showing the Save changes and Actions buttons and the Metrics, Logs, Response headers, Environment variables, Secrets, and Edge Storage tabs](/images/docs/fastedge/manage-apps/app-management-page-annotated.png) -- **Secrets**: Update or add secrets (encrypted environment variables). +

The following tabs are available on the management page:

-- **Edge Storage**: Update or add Edge Storage (key-value storage). +- **Metrics**: response status counts and runtime duration charts. +- **Logs**: enable log collection and filter log entries. +- **Response headers**: add HTTP headers to every application response. +- **Environment variables**: define configuration values the application reads at runtime. +- **Secrets**: link encrypted secrets from Secrets Manager to the application. +- **Edge Storage**: link key-value stores to the application. -To open the application management page: +

The table below describes when to use each configuration option:

-1\. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge** and choose the relevant page: **HTTP Applications** or **CDN Applications**. +| Feature | Use for | +|---------|---------| +| Response headers | HTTP headers added to every response — CORS, cache control, security headers | +| Environment variables | Configuration values available to the application at runtime, up to 64 KB each | +| Secrets | API keys, credentials, and other sensitive values encrypted at rest | +| Edge Storage | Shared mutable key-value data the application reads at runtime | +| Dictionary | Parameters over 64 KB and read-only edge node metadata — accessed from application code | -2\. On the **Applications** page, click the three-dot icon next to the application you want to configure. +## Application lifecycle -3\. Select **Manage**. +

Use the **Actions** button in the page header to control the application lifecycle — stop or restart it, deploy a new binary, save its configuration as a reusable template, or delete it entirely.

- - ![FastEdge applications - page](/images/docs/fastedge/manage-apps/manage-apps-menu.png) - +- **Stop** — pause the application. Stopped applications don't process requests. +- **Start** — resume a stopped application. +- **Edit application** — update the application name or description. +- **Update binary** — upload a new compiled Wasm binary. +- **Create template** — save the current configuration as a reusable template. +- **Delete** — permanently remove the application. -4\. Check and update your application's configuration as required. +![Application management page with the Actions menu open showing Stop, Edit application, Update binary, Create template, and Delete](/images/docs/fastedge/manage-apps/stop-app.png) -## Stop or start an application +

An application may also stop automatically if payment for the product fails. In that case, it can't be restarted until payment is completed.

-You can change the running state of your application and decide if you want to have it running and processing requests, or stopped. The latter might be useful if you need to update the application's configuration or want to upload a new version of the application's binary file. +## Metrics -An application can be stopped for the following reasons: +

The **Metrics** tab shows two charts: **Response Status** groups completed requests by HTTP status code, and **Runtime Duration (ms)** shows execution time per request in milliseconds. Use the time-range dropdown and the interval control in the chart header to adjust the view.

-- You manually stopped it, as described in the following instructions. You can restart the application at any time. +## Logs -- Payment for the product was unsuccessful. In this case, the application cannot be reactivated until payment is completed. +

Logging is disabled by default. After enabling, the application records logs for 30 minutes, then stops automatically.

-To manually stop or activate the application: +

To enable logging:

-1\. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge** and choose the relevant page: **HTTP Applications** or **CDN Applications**. +1. Select the **Logs** tab. -2\. On the **Applications** page, click the three-dot icon next to the application you want to configure. +2. Turn on the **Enable logging** toggle. -3\. Select **Manage**. +![Logs tab with the Enable logging toggle turned on and Minutes remaining showing 30](/images/docs/fastedge/manage-apps/view-logging.png) -4\. Click **Actions** and choose the relevant one: **Stop** or **Start**. +

The remaining logging time appears next to the toggle as **Minutes remaining: N**. To extend logging, turn the toggle off and on again.

- - ![FastEdge applications page](/images/docs/fastedge/manage-apps/stop-app.png) - +

Log entries appear in the table with the following columns:

-The application status will be changed respectively. +- **Client IP address** — IP of the client that sent the request. +- **Timestamp (UTC)** — time the request was received. +- **Edge name** — identifier of the edge node that handled the request. +- **Request ID** — unique identifier assigned to the request. +- **Logs** — application log output for that request. -## View and enable logging +

Use the text search field above the table to filter by log content, or select a date range. The **Refresh rate** dropdown controls how often the table updates — it defaults to 10 seconds when logging is active.

-If you want to record logs for your FastEdge application, make sure that you have the **Enable logging** toggle enabled. +## Application configuration - - ![FastEdge appl page with logging tab - open](/images/docs/fastedge/manage-apps/view-logging.png) - +

The **Response headers**, **Environment variables**, **Secrets**, and **Edge Storage** tabs each control a different aspect of how the application receives configuration and accesses external data at runtime. Click **Save changes** to apply any edits. The dictionary is a separate read-only data source that the application accesses directly from code.

-By default, FastEdge applications don't generate logs. After you turn on the Enable logging toggle, the application will record logs for 30 minutes. You can monitor the remaining logging time by checking the countdown next to the toggle. +### Response headers -After 30 minutes, logging will stop, and the application will revert to its default no-logging state. To start logging, enable the toggle again. +

Use response headers to add CORS, cache-control, security, or custom headers to every application response.

-You can filter log data according to the following criteria: +![Response headers tab with an Access-Control-Allow-Origin header set to https://example.com](/images/docs/fastedge/manage-apps/response-headers.png) -- **Timestamp**. Choose the date and time when the logs have been recorded. By default, the table displays data for the past hour. +

To add a header, click **Add response header**, enter the header name in the **Key** field and the value in the **Value** field, then click **Save changes**.

-- **Client IP address**. View logs collected for a particular IP. +### Environment variables -- **Edge name**. Search within the **Logs** column. +

Environment variables pass configuration values to the application at runtime. Each variable can store up to 64 KB of data; for larger values, define the parameter here and read it from code through the [dictionary](#dictionary) using the same key name.

-## Response Headers +![Environment variables tab with three variables configured showing key-value pairs](/images/docs/fastedge/manage-apps/env-vars.png) -On the **Response Headers** tab, you can update or enhance the functionality of your application by adding or modifying HTTP response headers. +

To add a variable, click **Add environment variable**, enter the variable name in the **Key** field and its value in the **Value** field, then click **Save changes**.

-These Response Headers will be added to every response. For example, you may include CORS (cross-origin resource sharing) headers in each response to ensure secure communication between origins. +

Access environment variables in code using the [JavaScript SDK](https://g-core.github.io/FastEdge-sdk-js/reference/fastedge/env/) or standard Rust `std::env::var("KEY_NAME")`.

- - ![FastEdge applications response - headers](/images/docs/fastedge/manage-apps/response-headers.png) - +### Secrets -## Environment Variables +

Use environment variables for ordinary configuration values. When a value is sensitive — an API key, access token, or password — store it as a secret instead.

-On the **Environment Variables** tab, you can update or enhance the functionality of your application by adding or modifying environment variables. +

Secrets let an application access sensitive values without storing them directly in its configuration. Each secret is stored in [Secrets Manager](/fastedge/secrets-manager/manage-secrets) and linked to the application under a local key name that the code uses to retrieve the value at runtime.

-For example, the following screenshots illustrate the configuration for a geo-location application. Environment variables are set based on the geo-IP of the client making the request. With this configuration, users will view different versions of a website based on their location. +![Secrets tab with ACCESS_KEY linked to the S3_ACCESS_TOKEN_BINARY_DUMP secret from Secrets Manager](/images/docs/fastedge/manage-apps/secrets.png) - - ![FastEdge applications environment - variables](/images/docs/fastedge/manage-apps/env-vars.png) - +

To link a secret:

- -**Info** +1. Click **Add secret**. -By using our [FastEdge SDK Javascript](https://g-core.github.io/FastEdge-sdk-js/reference/fastedge/env/) or [FastEdge SDK Rust](https://docs.rs/fastedge/latest/fastedge/dictionary/fn.get.html), you can configure these variables according to your use cases. +2. In the **Key** field, enter the name the application will use to reference the secret. - +3. In the second field, select a secret from Secrets Manager. To create a new secret first, select **Add secret** in the dropdown. -## Secrets +4. Click **Save changes**. -On the **Secrets** tab, you can update or enhance the functionality of your application by adding or modifying secrets. +

Access the secret in code using `secret::get("KEY_NAME")` in the [Rust SDK](https://docs.rs/fastedge/latest/fastedge/secret/index.html), or [`getSecret`](https://g-core.github.io/FastEdge-sdk-js/reference/fastedge/secret/get-secret/) in the JavaScript SDK.

- - ![FastEdge applications - secrets](/images/docs/fastedge/manage-apps/secrets.png) - +### Edge Storage -Providing a secret to your application: +

Edge Storage provides a shared key-value store that applications can read and update at runtime. Link a store under a local key name, and the code uses that name to open and query it.

-You define a name for the secret within the application and then select a secret from [Secrets Manager](/fastedge/secrets-manager/manage-secrets), linking it to the application. +![Edge Storage tab with BLACKLIST linked to the KNOWN_BAD_IP_ADDRESSES store](/images/docs/fastedge/manage-apps/storage.png) -- **ACCESS_KEY** - name as defined in the application. -- **S3_ACCESS_TOKEN_BINARY_DUMP** - secret that is linked to the application. +

To link a store:

-To access the secret within the application, use secret::get("ACCESS_KEY"), where ACCESS_KEY is the secret name defined in the application. +1. Click **Add Edge Storage**. - -**Info** +2. In the **Key** field, enter the name the application will use to open the store. -By using our [Javascript SDK](https://g-core.github.io/FastEdge-sdk-js/reference/fastedge/secret/get-secret/) or [Rust SDK](https://docs.rs/fastedge/latest/fastedge/secret/index.html), you can configure these secrets according to your use cases. +3. In the second field, select a store from [Edge Storage](/fastedge/kv-stores/manage-kv-store). To create a new store first, select **Add Edge Storage** in the dropdown. - +4. Click **Save changes**. -## Edge Storage +

Access the store in code using `Store::open("KEY_NAME")` in the [Rust SDK](https://docs.rs/fastedge/latest/fastedge/key_value/struct.Store.html), or [`open`](https://g-core.github.io/FastEdge-sdk-js/reference/fastedge/kv/open/) in the JavaScript SDK.

-On the **Edge Storage** tab, you can update or enhance the functionality of your application by adding or modifying edge storage. +### Dictionary - - ![FastEdge applications edge - storage](/images/docs/fastedge/manage-apps/storage.png) - +

The dictionary gives application code read-only access to edge node metadata that FastEdge populates automatically on every node, and to application parameters that exceed the 64 KB environment variable limit.

-Providing Edge Storage to your application: +**Edge node metadata** -You define a name for the store within the application and then select an edge store from [Edge Storage](/fastedge/kv-stores/manage-kv-store), linking it to the application. +

FastEdge automatically populates the following keys on every edge node. These values reflect the physical node handling each request:

-- **BLACKLIST** - name as defined in the application. -- **KNOWN_BAD_IP_ADDRESSES** - storage that is linked to the application. +| Key | Description | +|-----|-------------| +| `hostname` | Hostname of the edge node | +| `env` | Deployment environment: `prod` or `preprod` | +| `role` | Node role: `edge` or `shield` | +| `region` | Geographic region of the edge node: `africa`, `asia`, `au`, `cis`, `eu`, `latam`, `me`, `na`. Additional values may be returned for reseller networks. | +| `country` | Full name of the country where the node is located | +| `country2char` | ISO 3166-1 alpha-2 country code | +| `city` | City where the node is located | +| `dc` | Point of Presence (PoP) identifier | +| `ipv4_addr_ip` | IPv4 address of the edge node | +| `ipv6_addr_ip` | IPv6 address of the edge node | +| `ipv6_enabled` | Whether IPv6 is enabled on the node: `true` or `false` | -To access the storage within the application you would use `Store::open("BLACKLIST")` as this is the name as defined within the application. +

Built-in keys take priority over application parameters with the same name. To avoid unexpected behavior, don't use built-in key names as environment variable names.

- -**Info** +**Large application parameters** -By using our [Javascript SDK](https://g-core.github.io/FastEdge-sdk-js/reference/fastedge/kv/open/) or [Rust SDK](https://docs.rs/fastedge/latest/fastedge/key_value/struct.Store.html), you can configure the Edge Storage according to your use cases. +

Standard environment variable access is limited to 64 KB per value. For parameters that exceed this limit, define them on the **Environment variables** tab and read them through the dictionary using the same key name.

-
+**Read dictionary values in code** + +

In Rust, use the [`dictionary` module](https://docs.rs/fastedge/latest/fastedge/dictionary/index.html):

+ +```rust +use fastedge::dictionary; + +if let Some(value) = dictionary::get("country") { + // use value +} +``` + +

In JavaScript, dictionary values are exposed through `getEnv()` from the [`fastedge::env`](https://g-core.github.io/FastEdge-sdk-js/reference/fastedge/env/) module:

+ +```js +import { getEnv } from 'fastedge::env'; + +const country = getEnv('country'); +``` + +
+ + +

All management operations use the https://api.gcore.com/fastedge/v1/apps/{id} endpoint, where `id` is the numeric application identifier returned by GET /fastedge/v1/apps.

+ +

All requests authenticate with an [API token](/account-settings/api-tokens). Set it as an environment variable before running the examples:

+ +```bash +export GCORE_API_KEY="{YOUR_API_KEY}" +``` + +## Application lifecycle + +

To retrieve the current application state, including its configuration fields and binary ID:

+ +```bash +curl -X GET "https://api.gcore.com/fastedge/v1/apps/APP_ID" \ + -H "Authorization: APIKey $GCORE_API_KEY" +``` + +

The response includes all fields needed for subsequent PUT requests: `id`, `binary`, `name`, `status`, `rsp_headers`, `env`, `secrets`, and `stores`.

+ +

To stop the application, send a PUT request with `"status": 0`. To start it again, use `"status": 1`. The PUT body must include all current field values — use the GET response as the base and update only the fields that change.

+ +```bash +curl -X PUT "https://api.gcore.com/fastedge/v1/apps/APP_ID" \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "id": APP_ID, + "binary": BINARY_ID, + "name": "app-name", + "status": 0 + }' +``` + +

To delete the application permanently:

+ +```bash +curl -X DELETE "https://api.gcore.com/fastedge/v1/apps/APP_ID" \ + -H "Authorization: APIKey $GCORE_API_KEY" +``` + +## Metrics + +

Response Status and Runtime Duration are exposed through separate endpoints. **Response Status** groups completed requests by HTTP status code; **Runtime Duration** shows execution time per request in milliseconds. Both accept the same time-range parameters.

+ +```bash +# Response status counts +curl "https://api.gcore.com/fastedge/v1/stats/calls?from=2026-06-17T00:00:00Z&to=2026-06-17T23:59:59Z&step=3600&id=APP_ID" \ + -H "Authorization: APIKey $GCORE_API_KEY" + +# Runtime duration +curl "https://api.gcore.com/fastedge/v1/stats/app_duration?from=2026-06-17T00:00:00Z&to=2026-06-17T23:59:59Z&step=3600&id=APP_ID" \ + -H "Authorization: APIKey $GCORE_API_KEY" +``` + +

The `step` parameter specifies the aggregation interval in seconds. The `from` and `to` parameters use ISO 8601 UTC format.

+ +## Logs + +

Logging is disabled by default and runs for 30 minutes after being enabled, then turns off automatically. Enable it by setting `"debug": true` in a PUT request.

+ +```bash +curl -X PUT "https://api.gcore.com/fastedge/v1/apps/APP_ID" \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "id": APP_ID, + "binary": BINARY_ID, + "name": "app-name", + "status": 1, + "debug": true + }' +``` + +

The response includes a `debug_until` field with the UTC timestamp when logging will stop. To read log entries:

+ +```bash +curl "https://api.gcore.com/fastedge/v1/apps/APP_ID/logs?from=2026-06-17T00:00:00Z&to=2026-06-17T23:59:59Z&offset=0&limit=50" \ + -H "Authorization: APIKey $GCORE_API_KEY" +``` + +## Application configuration + +

Response headers, environment variables, secrets, and Edge Storage are all updated with a single PUT /fastedge/v1/apps/{id} request. The body replaces the entire configuration — fields omitted from the request are cleared. Read the current state with GET first and use it as the base.

+ +**Response headers** + +

Set headers in the `rsp_headers` object:

+ +```json +"rsp_headers": { + "Access-Control-Allow-Origin": "*", + "Cache-Control": "public, max-age=3600" +} +``` + +**Environment variables** + +

Set variables in the `env` object:

+ +```json +"env": { + "API_BASE_URL": "https://api.example.com", + "MAX_RETRIES": "3" +} +``` + +**Secrets** + +

To link a secret, get its numeric ID from GET /fastedge/v1/secrets, then reference it in the `secrets` object:

+ +```json +"secrets": { + "MY_API_KEY": {"id": 636} +} +``` + +**Edge Storage** + +

To link a key-value store, get its numeric ID from GET /fastedge/v1/kv, then reference it in the `stores` object:

+ +```json +"stores": { + "MY_STORE": {"id": 126} +} +``` + +

The following example updates all four configuration areas in one request:

+ +```bash +curl -X PUT "https://api.gcore.com/fastedge/v1/apps/APP_ID" \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "id": APP_ID, + "binary": BINARY_ID, + "name": "app-name", + "status": 1, + "rsp_headers": { + "Access-Control-Allow-Origin": "*" + }, + "env": { + "API_BASE_URL": "https://api.example.com" + }, + "secrets": { + "MY_API_KEY": {"id": 636} + }, + "stores": { + "MY_STORE": {"id": 126} + } + }' +``` + + +## Runtime data + +### Dictionary + +

The dictionary is populated automatically by FastEdge on every edge node and is not configurable through the API. Access it from application code using the SDK — see the Customer Portal tab for the full key reference and code examples.

+ +
+
diff --git a/fastedge/render-markdown.mdx b/fastedge/render-markdown.mdx new file mode 100644 index 000000000..0c7f2c078 --- /dev/null +++ b/fastedge/render-markdown.mdx @@ -0,0 +1,60 @@ +--- +title: Render Markdown at the edge +sidebarTitle: Markdown renderer +ai-navigation: Deploy the FastEdge Markdown renderer template to fetch Markdown files from a remote URL and return them as rendered HTML pages via the Customer Portal. +--- + +The Markdown renderer is a built-in FastEdge application that turns Markdown files into HTML pages — no custom code, no binary build, no rendering backend required. + +A common use case: documentation stored on GitHub or any static file server, served as a fully rendered site directly from the edge. + +The application maps incoming request paths to a configurable root URL. Set `BASE` to the root of the Markdown source — such as a GitHub raw content URL — and requests to the application automatically fetch and render the corresponding files. + +## Create the application + +1. In the [Gcore Customer Portal](https://portal.gcore.com), navigate to **FastEdge** > **HTTP Applications** > **Applications** and click **Create new application**. + +2. Scroll to **Create from a template** and click **Markdown renderer**. + + ![Create an application page showing Upload binary and Create from a template sections with Geolocation-based redirect and Markdown renderer cards](/images/docs/fastedge/geolocation-redirect/create-from-template-overview.png) + +3. Enter a **Name** for the application. The name becomes part of the deployment URL. + +4. Fill in the **Template environment variables**: + + - **BASE** (required): The root URL of the Markdown source. The application appends the incoming request's path to this value. Set it to the directory URL where the Markdown files live, with a trailing slash. Example: `https://raw.githubusercontent.com/G-Core/FastEdge-sdk-js/main/` + + - **HEAD** (optional): Raw HTML inserted verbatim into the `` tag of every rendered page. Use it to apply a stylesheet or add other head-level markup. Example: `` + + ![Markdown renderer form with BASE required field and optional HEAD field](/images/docs/fastedge/geolocation-redirect/markdown-renderer-form.png) + +5. (Optional) Configure response headers, environment variables, secrets, or [Edge Storage](/fastedge/kv-stores/manage-kv-store) — see [app management](/fastedge/manage-apps) for details on each option. + +6. Click **Save and deploy**. + +The application details page opens with the deployment URL in the format `https://-.fastedge.app`. + +## Test the application + +Request any Markdown file path from the app URL and inspect the response: + +```sh +curl -i https://-.fastedge.app/README.md +``` + +The response is an HTML document with `Content-Type: text/html`: + +``` +HTTP/1.1 200 OK +content-type: text/html; charset=utf-8 + +...

README

... +``` + +Opening the URL directly in a browser shows the rendered page. If the source file does not exist at the constructed URL, the application returns the upstream HTTP error code. + +To verify the source URL the application constructs, confirm that `BASE` + path returns HTTP 200 directly before deploying. + + +`BASE`, `HEAD`, and all other environment variables can be updated from the application management page without rebuilding or redeploying the application. + diff --git a/fastedge/secrets-manager/manage-secrets.mdx b/fastedge/secrets-manager/manage-secrets.mdx index 704667b32..6a5f69357 100644 --- a/fastedge/secrets-manager/manage-secrets.mdx +++ b/fastedge/secrets-manager/manage-secrets.mdx @@ -1,91 +1,219 @@ --- title: Secrets Manager -sidebarTitle: Managing secrets -ai-navigation: Create and manage encrypted secrets in FastEdge Secrets Manager with slot numbers and secret values, then access them in applications via JavaScript SDK and Rust SDK. +sidebarTitle: Manage secrets +ai-navigation: Create, edit, and delete encrypted secrets in FastEdge Secrets Manager via the Customer Portal or REST API, then link secrets to applications that read them at runtime. --- -Secrets Manager allows you to store encrypted values for use across our global edge network. +import { MethodSwitch, MethodSection } from "/snippets/method-switch.jsx"; -## Creating a secret + + -1\. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge** and choose the relevant page: **Secrets Manager**. +Secrets Manager stores encrypted values that FastEdge applications can read at runtime. Each secret has a name, an optional description, and one or more slots — each slot holds an independently encrypted value. Use slot `0` for a regular single-value secret. Multiple slots are used for rotation scenarios where different values become active at different times. -2\. In the top-right corner of the screen, click **Add secret**. +## Create a secret + +1. In the [Gcore Customer Portal](https://portal.gcore.com), navigate to **FastEdge** > **Secrets Manager**. + +2. Click **Add secret**. - ![FastEdge Secrets - Manager](/images/docs/fastedge/secret-manager/add-secret.png) +![Secrets Manager page with the Add secret button](/images/docs/fastedge/secrets-manager/manage-secrets/secrets-list.png) -3\. Enter a name for your secret and provide a description if needed. +3. Enter a **Name** and an optional **Description**. + +4. In the **Slots** section, enter a **Slot index** and the secret value in the **Value** field. Use `0` for a single-value secret. -4\. Provide a slot number (default 0), and your secret value to be encrypted. +5. Click **Encrypt**. The field shows "Encrypted Value" to confirm the value was encrypted. - ![FastEdge Secrets - Creation](/images/docs/fastedge/secret-manager/create-secret.png) +![Create secret form with name, description, and slot value encrypted](/images/docs/fastedge/secrets-manager/manage-secrets/create-secret-encrypted.png) -5\. Check all the settings. If everything is configured correctly, click **Save changes**. +6. Click **Save changes**. -**Warning** - -Once you save the secret, you won’t be able to view the original unencrypted value. You will only be able to replace it. - +Once saved, the original value cannot be viewed — only replaced. Encrypted values are stored separately from application data to protect against unauthorized access. -We store all encrypted variables in a separate table in the database to protect your information from potential security breaches or unauthorized access. +## Edit a secret -## Editing a secret +1. Navigate to **FastEdge** > **Secrets Manager**. -1\. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge** and choose the relevant page: **Secrets Manager**. - -2\. Find the secret you want to edit and click its name to open it. +2. Click the secret name to open the edit form. - ![FastEdge Secrets List](/images/docs/fastedge/secret-manager/secret-list.png) +![Secrets Manager list showing a secret entry](/images/docs/fastedge/secrets-manager/manage-secrets/secrets-list-with-item.png) -3\. You can replace an encrypted secret by clicking the edit button. +3. To replace an encrypted value, click the pencil icon next to the **Value** field, enter the new value, and click **Encrypt**. - ![FastEdge Secrets Edit](/images/docs/fastedge/secret-manager/edit-secret.png) +![Edit secret form with the pencil icon next to the encrypted value field](/images/docs/fastedge/secrets-manager/manage-secrets/edit-secret-form.png) -4\. Check all the settings. If everything is configured correctly, click **Save changes**. +4. Click **Save changes**. -## Deleting a secret +## Delete a secret -1\. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge** and choose the relevant page: **Secrets Manager**. +1. Navigate to **FastEdge** > **Secrets Manager**. -2\. Find the secret you want to delete. click the three-dot icon next to the secret and select delete. +2. Click the three-dot icon (**...**) next to the secret and select **Delete**. - ![FastEdge Delete List](/images/docs/fastedge/secret-manager/delete-list.png) +![Secrets Manager list with the three-dot menu showing Edit and Delete options](/images/docs/fastedge/secrets-manager/manage-secrets/delete-secret-menu.png) -3\. Confirm deletion - - -**Info** +3. Click **Yes, delete** to confirm. -You can only delete secrets **NOT** in use. If the Secret is assigned to an application it will prompt you to remove it. - - - ![FastEdge Delete - Detachment](/images/docs/fastedge/secret-manager/delete-detachment.png) - - - - -## Accessing Secrets in applications - -For more information regarding Secrets usage in applications see the [JavaScript SDK](https://g-core.github.io/FastEdge-sdk-js/reference/fastedge/secret/get-secret/) and the [Rust SDK](https://docs.rs/fastedge/latest/fastedge/secret/index.html) + +A secret assigned to an application cannot be deleted — remove it from the application first. Deleted secrets cannot be restored. + - -**Info** +## Secrets in applications + +Creating a secret only stores the encrypted value. To make it available to an application, link it from the application's **Secrets** tab in [manage apps](/fastedge/manage-apps#secrets). The application reads the value at runtime using the secret name and slot index via the [JavaScript SDK](https://g-core.github.io/FastEdge-sdk-js/reference/fastedge/secret/get-secret/) or [Rust SDK](https://docs.rs/fastedge/latest/fastedge/secret/index.html). + + + + +Secrets Manager stores encrypted values that FastEdge applications read at runtime. The API covers the full secret lifecycle: create, read, update, and delete. Each secret contains one or more slots — a slot holds an encrypted value and a numeric identifier. Use slot `0` for single-value secrets; multiple slots support time-based rotation using Unix timestamps as identifiers. + +

All requests authenticate with an [API token](/account-settings/api-tokens). Set it as an environment variable before running the examples:

+ +```bash +export GCORE_API_KEY="{YOUR_API_KEY}" +``` + +## Create a secret + +```bash +curl -X POST https://api.gcore.com/fastedge/v1/secrets \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "my-app-secret", + "comment": "API key for external service", + "secret_slots": [ + { + "slot": 0, + "value": "your-secret-value" + } + ] + }' +``` + +The response returns the created secret with its assigned ID: + +```json +{ + "id": 638, + "name": "my-app-secret", + "comment": "API key for external service", + "secret_slots": [ + { + "slot": 0, + "checksum": "03a0986e7619f1d45d12369a1a58d2bbfc3e9f8aea9c5fe84b86087ff8941abb" + } + ] +} +``` + +The `checksum` field identifies the stored encrypted value. The original value is never returned. + +## List secrets + +```bash +curl https://api.gcore.com/fastedge/v1/secrets \ + -H "Authorization: APIKey $GCORE_API_KEY" +``` + +Optional query parameters: + +| Parameter | Type | Description | +|-----------|------|-------------| +| `app_id` | integer | Filter secrets assigned to the specified application | +| `secret_name` | string | Filter by exact secret name | + +Response: + +```json +{ + "count": 2, + "secrets": [ + { + "id": 636, + "name": "docs-audit-secret", + "comment": "", + "app_count": 0 + }, + { + "id": 638, + "name": "my-app-secret", + "comment": "API key for external service", + "app_count": 1 + } + ] +} +``` + +## Get a secret + +```bash +curl https://api.gcore.com/fastedge/v1/secrets/SECRET_ID \ + -H "Authorization: APIKey $GCORE_API_KEY" +``` + +Response includes the slot list with checksums: + +```json +{ + "name": "my-app-secret", + "comment": "API key for external service", + "app_count": 1, + "secret_slots": [ + { + "slot": 0, + "checksum": "03a0986e7619f1d45d12369a1a58d2bbfc3e9f8aea9c5fe84b86087ff8941abb" + } + ] +} +``` + +## Update a secret + +Use `PATCH` to update the name, description, or slot values. Only the fields included in the request body are changed. + +```bash +curl -X PATCH https://api.gcore.com/fastedge/v1/secrets/SECRET_ID \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "comment": "Updated description", + "secret_slots": [ + { + "slot": 0, + "value": "new-secret-value" + } + ] + }' +``` + +The response returns the full updated secret object, including the new checksum for the updated slot. + +## Delete a secret + +```bash +curl -X DELETE "https://api.gcore.com/fastedge/v1/secrets/SECRET_ID?force=true" \ + -H "Authorization: APIKey $GCORE_API_KEY" +``` + +A successful response returns HTTP 204 with no body. -In order to use Secrets in an application it must first be linked to the application. See [Managing Applications - Secrets](/fastedge/manage-apps#secrets) + +The `force=true` parameter is required when the secret has encrypted slots. Without it, the request returns 400. If the secret is assigned to an application, `force=true` also removes it from all assigned applications before deletion. + - +
+
diff --git a/fastedge/secrets-manager/slots.mdx b/fastedge/secrets-manager/slots.mdx index 6e4b034a8..1ac57e226 100644 --- a/fastedge/secrets-manager/slots.mdx +++ b/fastedge/secrets-manager/slots.mdx @@ -1,64 +1,124 @@ --- -title: Secrets Slots -sidebarTitle: Secrets Slots -ai-navigation: Configure FastEdge Secrets Slots for secret rotation by storing multiple encrypted secret versions with slot indices, enabling runtime secret updates via get_secret API without deleting old values and supporting token validation against specific secret versions using slot indices or timestamps. +title: Secret rotation with slots +sidebarTitle: Secret rotation with slots +ai-navigation: Use FastEdge Secrets Manager slots to implement secret rotation — each slot stores a separate encrypted value identified by a numeric index or Unix timestamp, enabling runtime rotation without application redeployment. --- -Secrets Slots is a mechanism by which you can empower secret rotation. +import { MethodSwitch, MethodSection } from "/snippets/method-switch.jsx"; -When requesting a secret within an application ( get_secret ) the encrypted secret provided will always be the slot with the maximum slot index. + + -So adding a new encrypted value with a higher slot index, will update the secret at runtime without having to delete / replace old secret values. +A secret can hold multiple encrypted values in separate slots. Each slot has a numeric **Slot index** and an independently encrypted value. -### Slots and secret rollover +## Slot selection logic -Using `get_effective_at` to access different slots within a given secret and how to use slots. +The SDK selects a slot based on its index. Which slot is returned depends on the function used: - -**Info** +- **`get_secret(name)`** — always returns the value from the slot with the **highest** index +- **`get_effective_at(name, n)`** — returns the value from the slot with the **highest index that is ≤ n** -For more information regarding secret usage in applications see the [JavaScript SDK](https://g-core.github.io/FastEdge-sdk-js/reference/fastedge/secret/get-secret/) and the [Rust SDK](https://docs.rs/fastedge/latest/fastedge/secret/index.html) +## Slot indices for password rotation - +In this pattern, slot indices are arbitrary integers that represent password versions. Applications store the slot index used to sign a token in the token payload, then pass that index to `get_effective_at` when validating. -The following are examples of slots usage to manage secret rollover within your own applications. This could be achieved in many -different ways. +The secret below has two slots: -##### **Example 1** (Slots as indices) + +![Create secret form with two slots — index 0 for original password and index 5 for updated password](/images/docs/fastedge/secrets-manager/slots/slots-example-indices.png) + + +With this configuration: + +- `get_effective_at("token-secret", 0)` returns `original_password` +- `get_effective_at("token-secret", 3)` returns `original_password` (highest slot ≤ 3 is slot 0) +- `get_effective_at("token-secret", 5)` returns `updated_password` +- `get_effective_at("token-secret", 7)` returns `updated_password` (highest slot ≤ 7 is slot 5) + +Tokens signed with the old password carry index 0 and continue to validate correctly. New tokens carry index 5 and use the updated password. Both coexist without requiring any immediate migration. -Validating a token against a specific version of a secret. +## Unix timestamps for time-based rotation -Having created a secret: +In this pattern, slot indices are Unix timestamps indicating when each password version becomes active. Applications pass the token issue time (`iat` claim) to `get_effective_at`. - ![Secret Slots Indices - Example](/images/docs/fastedge/secret-manager/slots-example-indices.png) +![Create secret form with two slots — index 0 for original password and index 1741790697 for new password](/images/docs/fastedge/secrets-manager/slots/slots-example-timestamps.png) -It would now be easy enough to also provide the `slot` value within the tokens claims as to which -password it should validate against. This would allow you to slowly rollover from one password to -another and keep all users able to refresh their tokens without issues, as each users token also -carries the data to know which password was still in use when it was issued. +With slot 0 holding `original_password` and slot `1741790697` (Wed Mar 12 2025 14:44:57 UTC) holding `new_password`: -It always returns `effectiveAt >= secret_slots.slot` +- Any token with `iat` before `1741790697` validates against `original_password` +- Any token issued after that timestamp validates against `new_password` -So a request to: +Rotation happens automatically at the specified time — no redeployment required. -- `secret::get_effective_at("token-secret", 0)` would return `original_password` -- `secret::get_effective_at("token-secret", 3)` would return `original_password` -- `secret::get_effective_at("token-secret", 5)` would return `updated_password` -- `secret::get_effective_at("token-secret", 7)` would return `updated_password` + + -This `>=` logic makes it very easy to implement the following example. +Slots are stored as part of the secret object. Use `PATCH` to add rotation slots without removing existing ones. Use `PUT` only when replacing the entire secret configuration. -##### **Example 2** (Slots as timestamps) +

All requests authenticate with an [API token](/account-settings/api-tokens). Set it as an environment variable before running the examples:

-Validating a token against a specific version of a secret using timestamps: +```bash +export GCORE_API_KEY="{YOUR_API_KEY}" +``` - - ![Secret Slots Timestamp - Example](/images/docs/fastedge/secret-manager/slots-example-timestamps.png) - +## Create a secret with multiple slots + +Pass all slots in a single request to create a pre-configured rotation setup: + +```bash +curl -X POST https://api.gcore.com/fastedge/v1/secrets \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "token-secret", + "comment": "Password for token validation", + "secret_slots": [ + {"slot": 0, "value": "original_password"}, + {"slot": 1741790697, "value": "new_password"} + ] + }' +``` + +## Add a rotation slot + +To add a new slot to an existing secret without removing the current ones, use `PATCH` with only the new slot: + +```bash +curl -X PATCH https://api.gcore.com/fastedge/v1/secrets/SECRET_ID \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "secret_slots": [ + {"slot": 1741790697, "value": "new_password"} + ] + }' +``` + +`PATCH` adds or updates only the slots listed in the request — existing slots at other indices are preserved. + + +`PUT` replaces the entire secret including all slots. Any slot not included in a `PUT` request is permanently removed. Use `PATCH` for rotation to preserve existing slots. + + +## Remove an old slot after rotation is complete + +Once all clients have migrated to the new password, remove the old slot by sending a `PUT` with only the current slot: + +```bash +curl -X PUT https://api.gcore.com/fastedge/v1/secrets/SECRET_ID \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "token-secret", + "secret_slots": [ + {"slot": 1741790697, "value": "new_password"} + ] + }' +``` + +This removes slot 0 and leaves only the new slot. After this, `get_secret` and `get_effective_at` with any index ≥ 0 both return the new password. -As you can see any token being validated with an `iat` claim time before 1741790697 would use the -`original_password` and any token after this time would start to use the `new_password` +
+
diff --git a/fastedge/snippets/fastedge-cdn-integration.mdx b/fastedge/snippets/fastedge-cdn-integration.mdx deleted file mode 100644 index 599157b84..000000000 --- a/fastedge/snippets/fastedge-cdn-integration.mdx +++ /dev/null @@ -1,257 +0,0 @@ -Integrate your CDN resource with FastEdge if you need to **introduce additional functionality** to Gcore CDN and customize its behavior for various use cases. - -Such a setup allows you to extend the CDN beyond standard features and implement advanced logic for: - -- Authentication checks. Deploy FastEdge apps based on the JWT authentication template or develop a custom authentication functionality. -- Custom headers modification. Adjust header information on requests for personalized and more secure content delivery. -- Custom access rules. Use advanced geo-blocking and time-based blocking to control user access to your content and mitigate potential threats. - -## How it works - -Unlike traditional HTTP applications, a CDN application in FastEdge must be developed according to the [Proxy-Wasm (WebAssembly for Proxies)](https://github.com/proxy-wasm/spec) specification. This ensures compatibility and standardization across different CDN environments. - -The application is called at the early stage of CDN processing, allowing for immediate intervention and customization. We're actively working on new interception points across the CDN workflow to cover many use cases. - -The FastEdge application can be invoked at the following stages of the CDN processing workflow: - -- **On request headers:** when we receive an HTTP request from a client. -- **On request body:** when we receive an HTTP request body from a client. -- **On response headers:** before we start sending HTTP response headers to a client. -- **On response:** before?we start sending an HTTP response to a client. - -You can only configure **one application per stage**. - -## Set up FastEdge integration with the CDN - -To get started, you need a CDN resource configured for your origin. If you don't have Gcore CDN set up, follow the instructions in this guide: [Create a CDN resource](/cdn/getting-started/create-a-cdn-resource/overview). - -### Step 1. Create a FastEdge application - -You can deploy an application from a predefined template or from a custom Wasm file. If you choose the latter option, ensure your Wasm binary file complies with the [WebAssembly standard for proxies](https://github.com/proxy-wasm/spec). - - - - Currently, you can use a predefined template to enable authentication in your application. The template is configured to verify the JSON Web Token (JWT) in the request header. - - To deploy an application from the template: - - 1. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge**. - 2. Open the **CDN Applications** page and click **Create new application**. - - - ![Create FastEdge application button](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-apps-page-create-app.png) - - 3. In the **Create from a template** section, choose **Validate JWT in Authorization header**. - - - ![Create from a template section with jwt validation template](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/validate-jwt.png) - - 4. Enter a name for your application and, optionally, update its description. - 5. Add required environment variables, such as a token signing key that will be used for authentication checks. - - - ![JWT template configuration menu](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-from-template-setup.png) - - 6. Click **Save and deploy**. - - Your application has been successfully deployed and can now be accessed through the CDN. - - - ![A page with app deployment confirmation](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-created.png) - - If you need to adjust the configuration, click **Actions** \> **Edit application**. - - - ![A page with app deployment confirmation](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/actions-edit-app-from-template.png) - - - - - If you want to deploy a FastEdge application from your own binary, check the examples of custom implementation in our repository: [FastEdge application examples](https://github.com/G-Core/FastEdge-examples). - - To deploy a FastEdge application from your own binary: - - 1\. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge**. - 2\. Open the **CDN Applications** page and click **Create new application**. - - - ![Create FastEdge application button](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-apps-page-create-app.png) - - 3\. Click **Upload binary**. - - - ![Create custom application section](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-apps-upload-binary.png) - - - 4\. Choose your custom binary file. - - ![Add raw binary dialog](/images/docs/fastedge/getting-started/create-fastedge-apps/upload-binary-dialog.png) - - 5. Enter a name for your application and, optionally, add a description. - 6. Add required environment variables that will be used for authentication checks. Enter the data as key-value pairs. - - - ![Custom app configuration menu](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-setup.png) - - - - **Info** - - If you're adding sensitive information or want to ensure that any data in the app's configuration remains secure, click **\+ Add Secret** and use the [Secrets Manager](/fastedge/secrets-manager/manage-secrets). - - - - 7. Click **Save and deploy**. - - Your application has been successfully deployed and can now be referenced from CDN resource settings. To adjust the configuration, click **Actions** \> **Edit application**. - - - ![A page with app deployment confirmation](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/actions-edit-app.png) - - - - - -### Step 2. Enable FastEdge functions for your CDN resource - -You can enable the configured Wasm functionality for the whole CDN resource or just some URLs. - - - - 1. In the Gcore Customer Portal, navigate to **CDN**. - 2. Find the resource you want to integrate with FastEdge and open the **resource settings**. - - - ![CDN resources page with resource settings context menu](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-resource-settings-button.png) - - 3. Scroll the page down to the **FastEdge apps** section and enable the toggle for the event you need. - - Currently, we support four events: **On request headers**, **on request body**, **on response headers**, and **on response body**. - - - Cdn Fast Edge 1 Pn - - 4. Choose your application from the dropdown. - - - Cdn Fast Edge 2 Pn - - 5. (Optional) **Select the Interrupt request processing in case of error** checkbox. - - - **Info** - - The **Interrupt request processing in case of error** checkbox is enabled by default. This ensures that any errors on the FastEdge side will be returned to the browser with the relevant response code. If you disable the checkbox, CDN will ignore the error and pass requests directly to the origin. For security considerations, we recommend keeping this checkbox active. - - 6. Click **Save**. - - - - You can set up a function within your uploaded FastEdge application to manage incoming request headers only for specific URLs. For example, protect some parts of your content with a JWT token, and keep the other URLs unaffected. - - To enable the function for specific URLs: - - 1. In the Gcore Customer Portal, navigate to **CDN**. - 2. Find the resource you want to integrate with FastEdge and open the resource settings. - 3. Click **Rules** \> **Create rule**. - - - ![CDN resource settings with open Rules tab](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-settings-rules-section.png) - - 4. Click **Create blank rule**. - 5. Give your rule a name. - 6. In the **Match criteria** section, specify the content affected by the function configured in your FastEdge application. - 7. In the **Options** section, click **Add option**. - 8. Scroll the page down to the **FastEdge apps** section and enable the toggle for the event you need. - - Currently, we support four events: **On request headers**, **on request body**, **on response headers**, and **on response body**. - - - Cdn Fast Edge 1 Pn - - 9. Choose your application from the dropdown. - - - Cdn Fast Edge 2 Pn - - 10. (Optional) **Select the Interrupt request processing in case of error** checkbox. - - - ![Enable FastEdge apps section in rule options dialog](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/rule-options-fastedge-app-enable.png) - - - **Info** - - The **Interrupt request processing in case of error** checkbox is enabled by default. This ensures that any errors on the FastEdge side will be returned to the browser with the relevant response code. - - If you disable the checkbox, CDN will ignore the error and pass requests directly to the origin. For security considerations, we recommend keeping this checkbox active. - - 12. Click **Create rule**. - - - - -## Disconnect FastEdge from CDN - -If you no longer need to use the functionality configured in your FastEdge application, you can disable the FastEdge functions for your CDN resource. - -The steps will slightly differ depending on whether you remove FastEdge from **the whole CDN resource or just specific URLs**. - -1. In the Gcore Customer Portal, navigate to **CDN**. -2. Find the resource integrated with FastEdge and open the **resource settings**. - - - ![CDN resources page with resource settings context - menu](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-resource-settings-button.png) - - -3. If you enabled FastEdge for a **whole CDN resource**, disable the toggles you no longer need. -4. If you enabled FastEdge just for **particular paths**, open the **Rules** page and disable the toggle for the required rule. -5. Click **Save changes**. - -You've successfully disconnected your CDN resource from FastEdge. - -## Delete CDN application in FastEdge - - - **Info** - -**You can't delete an enabled FastEdge application connected to a CDN resource**. To remove the application, disconnect it from the CDN resource first. - - - -To delete an application: - -1. In the Gcore Customer Portal, navigate to **FastEdge**. -2. Open the **CDN Applications** page and click the three-dot icon next to the application that you want to remove. - - - ![FastEdge app settings with delete - button](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/remove-app-fstedge.png) - - -3. Click **Delete**. -4. Confirm your action by clicking **Yes, delete**. - - - ![Confirm app deletion - dialog](/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/confirm-deletion.png) - - -You've successfully removed your CDN application from Gcore FastEdge. diff --git a/fastedge/troubleshooting.mdx b/fastedge/troubleshooting.mdx index c1d42b999..98c18e6c1 100644 --- a/fastedge/troubleshooting.mdx +++ b/fastedge/troubleshooting.mdx @@ -1,88 +1,96 @@ --- title: Troubleshooting sidebarTitle: Troubleshooting -ai-navigation: Diagnose FastEdge application failures using HTTP status codes 530 (internal error), 531 (memory limit exceeded), 532 (timeout), and 533 (crash) to identify root causes and access FastEdge SDK Rust, JavaScript, AssemblyScript, and development tools for resolution. +ai-navigation: Diagnose FastEdge application failures using HTTP status codes 530 (initialization failed), 531 (runtime error), 532 (timeout), and 533 (memory limit exceeded). Includes debug logging via API, platform limits, and SDK-specific notes for Rust and JavaScript. --- -If you're having issues with your FastEdge application, the following section offers helpful tips and troubleshooting suggestions. - -### HTTP status codes - -If your application is correctly configured and works as expected, FastEdge will return the expected status code, such as "200 OK." - -However, in some exceptional situations, you might get the following status codes. Check the descriptions to understand the root cause. - -| Status code | Description | -| ----------- | -------------------------------------------------- | -| 530 | Internal FastEdge error. | -| 531 | Application has exceeded the allowed memory limit. | -| 532 | Application has timed out. | -| 533 | Application has crashed. | - -### Useful resources - -- **FastEdge Examples** - - - FastEdge-examples Repository - - -- **FastEdge SDK Rust** - - - FastEdge SDK Rust Repository - - - - FastEdge docs.rs - - -- **FastEdge SDK Javascript (HTTP apps)** - - - FastEdge SDK JS Repository - - - - Javascript Reference Documentation - - -- **FastEdge SDK AssemblyScript (CDN apps)** - - - FastEdge Proxy-Wasm SDK - - -- **FastEdge Development Tools** - - - FastEdge MCP Server - - - - FastEdge VSCode Extension - +When a FastEdge application fails, the response includes a FastEdge-specific 5xx status code. The code identifies whether the failure happened during initialization, execution, timeout, or memory allocation. + +Start by identifying the returned status code. Then enable debug logging to capture application output and investigate the root cause. + +## HTTP error codes + +| Code | Meaning | Common causes | +| ---- | ------- | ------------- | +| 530 | Application initialization failed | Missing or invalid environment variable, wrong compilation target, corrupt binary | +| 531 | Runtime error — unhandled exception | Rust panic, JavaScript `TypeError`, failed outbound request, unexpected `null` | +| 532 | Execution timed out | Handler exceeded the execution time limit; check for infinite loops, expensive processing, or slow outbound calls | +| 533 | Memory limit exceeded | Application allocated more memory than the plan allows | + +## Debug logging + +Production applications do not write logs by default. Enable debug mode before reproducing the issue to capture `console.log` output (JavaScript) or `println!` output (Rust). + +Enable debug mode: + +```bash +curl -X PATCH "https://api.gcore.com/fastedge/v1/apps/{app_id}" \ + -H "Authorization: APIKey $GCORE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"debug": true}' +``` + +Debug mode stays active for 30 minutes and then turns off automatically. Reproduce the failure, then retrieve the logs: + +```bash +curl "https://api.gcore.com/fastedge/v1/apps/{app_id}/logs" \ + -H "Authorization: APIKey $GCORE_API_KEY" +``` + +Available query parameters: `from`, `to`, `edge` (specific PoP), `client_ip`, `request_id`, `search`. + +## Platform limits + +Exceeding the limits below triggers a 532 (timeout) or 533 (memory) response. Check which plan your application is on if you see these codes repeatedly. + +| Resource | Basic | Pro | +| -------- | ----- | --- | +| Execution time | 50 ms | 200 ms | +| Memory | 128 MB | 256 MB | +| Outbound requests | 5 per invocation | 20 per invocation | +| Request / response body | 1 MB | 5 MB | +| Binary size | ~50 MB | ~50 MB | + +## Common application issues + +### Rust: log output not appearing + +`eprintln!` writes to stderr, which FastEdge does not capture. Use `println!` for any output that should appear in debug logs. + +### JavaScript: unavailable APIs + +The following are not available inside FastEdge JavaScript applications: + +- Node.js built-ins: `node:crypto`, `node:fs`, `node:buffer`, `process`, `require` +- `WebSocket` +- Web Cache API — use the [Cache module](/fastedge/cache) (`import { Cache } from 'fastedge::cache'`) instead + +## Local testing + +Before deploying, test your application locally using the FastEdge CLI. See [FastEdge CLI](/fastedge/fastedge-cli) for installation and full usage. + +```bash +# Run a Wasm binary as a local HTTP server +fastedge-run http -w ./app.wasm --port 8080 + +# Launch the visual debugger at http://localhost:3000 +fastedge-test +``` + +For JavaScript applications, `npm run debug` starts the same visual debugger. + +## Related resources + +| Resource | Link | +| -------- | ---- | +| Rust SDK examples | [github.com/G-Core/FastEdge-sdk-rust/examples](https://github.com/G-Core/FastEdge-sdk-rust/examples) | +| JavaScript SDK examples | [github.com/G-Core/FastEdge-sdk-js/examples](https://github.com/G-Core/FastEdge-sdk-js/examples) | +| AssemblyScript SDK examples | [github.com/G-Core/proxy-wasm-sdk-as/examples](https://github.com/G-Core/proxy-wasm-sdk-as/examples) | +| Rust SDK | [github.com/G-Core/FastEdge-sdk-rust](https://github.com/G-Core/FastEdge-sdk-rust) | +| Rust API reference | [docs.rs/fastedge](https://docs.rs/fastedge/latest/fastedge/) | +| JavaScript SDK | [github.com/G-Core/FastEdge-sdk-js](https://github.com/G-Core/FastEdge-sdk-js) | +| JavaScript reference | [g-core.github.io/FastEdge-sdk-js](https://g-core.github.io/FastEdge-sdk-js/) | +| AssemblyScript SDK (CDN apps) | [github.com/G-Core/proxy-wasm-sdk-as](https://github.com/G-Core/proxy-wasm-sdk-as) | +| MCP server | [github.com/G-Core/FastEdge-mcp-server](https://github.com/G-Core/FastEdge-mcp-server) | +| VSCode extension | [github.com/G-Core/FastEdge-vscode](https://github.com/G-Core/FastEdge-vscode) | +| FastEdge Test | [github.com/G-Core/FastEdge-test](https://github.com/G-Core/FastEdge-test) | diff --git a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/actions-edit-app-from-template.png b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/actions-edit-app-from-template.png new file mode 100644 index 000000000..d7eb47f11 Binary files /dev/null and b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/actions-edit-app-from-template.png differ diff --git a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/actions-edit-app.png b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/actions-edit-app.png new file mode 100644 index 000000000..20194a7da Binary files /dev/null and b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/actions-edit-app.png differ diff --git a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-created.png b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-created.png new file mode 100644 index 000000000..171aedcb2 Binary files /dev/null and b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-created.png differ diff --git a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-from-template-setup.png b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-from-template-setup.png new file mode 100644 index 000000000..1a284772f Binary files /dev/null and b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-from-template-setup.png differ diff --git a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-setup.png b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-setup.png new file mode 100644 index 000000000..da3e5053a Binary files /dev/null and b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-setup.png differ diff --git a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-apps-page-create-app.png b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-apps-page-create-app.png new file mode 100644 index 000000000..4900a6844 Binary files /dev/null and b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-apps-page-create-app.png differ diff --git a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-apps-upload-binary.png b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-apps-upload-binary.png new file mode 100644 index 000000000..873b6c775 Binary files /dev/null and b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-apps-upload-binary.png differ diff --git a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-1.png b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-1.png new file mode 100644 index 000000000..b25343d4b Binary files /dev/null and b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-1.png differ diff --git a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-2.png b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-2.png new file mode 100644 index 000000000..9e0616360 Binary files /dev/null and b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-2.png differ diff --git a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-resource-settings-button.png b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-resource-settings-button.png new file mode 100644 index 000000000..31e0e4467 Binary files /dev/null and b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-resource-settings-button.png differ diff --git a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-settings-rules-section.png b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-settings-rules-section.png new file mode 100644 index 000000000..f092b20a5 Binary files /dev/null and b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-settings-rules-section.png differ diff --git a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/confirm-deletion.png b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/confirm-deletion.png new file mode 100644 index 000000000..cead32101 Binary files /dev/null and b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/confirm-deletion.png differ diff --git a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/remove-app-fstedge.png b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/remove-app-fstedge.png new file mode 100644 index 000000000..4c6a22106 Binary files /dev/null and b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/remove-app-fstedge.png differ diff --git a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/rule-options-fastedge-app-enable.png b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/rule-options-fastedge-app-enable.png new file mode 100644 index 000000000..7a574acc0 Binary files /dev/null and b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/rule-options-fastedge-app-enable.png differ diff --git a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/upload-binary-dialog.png b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/upload-binary-dialog.png new file mode 100644 index 000000000..da3e5053a Binary files /dev/null and b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/upload-binary-dialog.png differ diff --git a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/validate-jwt.png b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/validate-jwt.png new file mode 100644 index 000000000..bad712866 Binary files /dev/null and b/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/validate-jwt.png differ diff --git a/images/docs/fastedge/create-manage-templates/create-template-button.png b/images/docs/fastedge/create-manage-templates/create-template-button.png index b56283bec..0ef4d6b8f 100644 Binary files a/images/docs/fastedge/create-manage-templates/create-template-button.png and b/images/docs/fastedge/create-manage-templates/create-template-button.png differ diff --git a/images/docs/fastedge/create-manage-templates/create-template-from-app.png b/images/docs/fastedge/create-manage-templates/create-template-from-app.png index e3e763b53..680fc19f8 100644 Binary files a/images/docs/fastedge/create-manage-templates/create-template-from-app.png and b/images/docs/fastedge/create-manage-templates/create-template-from-app.png differ diff --git a/images/docs/fastedge/built-in-templates/create-from-template-overview.png b/images/docs/fastedge/geolocation-redirect/create-from-template-overview.png similarity index 100% rename from images/docs/fastedge/built-in-templates/create-from-template-overview.png rename to images/docs/fastedge/geolocation-redirect/create-from-template-overview.png diff --git a/images/docs/fastedge/built-in-templates/geolocation-redirect-form.png b/images/docs/fastedge/geolocation-redirect/geolocation-redirect-form.png similarity index 100% rename from images/docs/fastedge/built-in-templates/geolocation-redirect-form.png rename to images/docs/fastedge/geolocation-redirect/geolocation-redirect-form.png diff --git a/images/docs/fastedge/built-in-templates/markdown-renderer-form.png b/images/docs/fastedge/geolocation-redirect/markdown-renderer-form.png similarity index 100% rename from images/docs/fastedge/built-in-templates/markdown-renderer-form.png rename to images/docs/fastedge/geolocation-redirect/markdown-renderer-form.png diff --git a/images/docs/fastedge/getting-started/create-fastedge-apps/deploy-form-config-sections.png b/images/docs/fastedge/getting-started/create-fastedge-apps/deploy-form-config-sections.png new file mode 100644 index 000000000..6773967be Binary files /dev/null and b/images/docs/fastedge/getting-started/create-fastedge-apps/deploy-form-config-sections.png differ diff --git a/images/docs/fastedge/getting-started/create-fastedge-apps/http-app-created-from-template.png b/images/docs/fastedge/getting-started/create-fastedge-apps/http-app-created-from-template.png deleted file mode 100644 index bba487583..000000000 Binary files a/images/docs/fastedge/getting-started/create-fastedge-apps/http-app-created-from-template.png and /dev/null differ diff --git a/images/docs/fastedge/getting-started/create-fastedge-apps/http-app-created.png b/images/docs/fastedge/getting-started/create-fastedge-apps/http-app-created.png deleted file mode 100644 index 7a6194a07..000000000 Binary files a/images/docs/fastedge/getting-started/create-fastedge-apps/http-app-created.png and /dev/null differ diff --git a/images/docs/fastedge/getting-started/create-fastedge-apps/http-app-details-url-active.png b/images/docs/fastedge/getting-started/create-fastedge-apps/http-app-details-url-active.png new file mode 100644 index 000000000..7aee7d4be Binary files /dev/null and b/images/docs/fastedge/getting-started/create-fastedge-apps/http-app-details-url-active.png differ diff --git a/images/docs/fastedge/getting-started/create-fastedge-apps/http-app-from-template-setup.png b/images/docs/fastedge/getting-started/create-fastedge-apps/http-app-from-template-setup.png deleted file mode 100644 index 0199f1318..000000000 Binary files a/images/docs/fastedge/getting-started/create-fastedge-apps/http-app-from-template-setup.png and /dev/null differ diff --git a/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-application-list-edge-storage.png b/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-application-list-edge-storage.png new file mode 100644 index 000000000..79f14e48a Binary files /dev/null and b/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-application-list-edge-storage.png differ diff --git a/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-application-list.png b/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-application-list.png deleted file mode 100644 index 085418ddd..000000000 Binary files a/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-application-list.png and /dev/null differ diff --git a/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-create-app-env-vars.png b/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-create-app-env-vars.png deleted file mode 100644 index eacc46393..000000000 Binary files a/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-create-app-env-vars.png and /dev/null differ diff --git a/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-create-app.png b/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-create-app.png deleted file mode 100644 index 3e453ad86..000000000 Binary files a/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-create-app.png and /dev/null differ diff --git a/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-create-from-template.png b/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-create-from-template.png index de7413146..38f70420d 100644 Binary files a/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-create-from-template.png and b/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-create-from-template.png differ diff --git a/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-list-create-button.png b/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-list-create-button.png new file mode 100644 index 000000000..1196e9efa Binary files /dev/null and b/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-list-create-button.png differ diff --git a/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-upload-binary.png b/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-upload-binary.png index ea7c2e6d9..ba7053713 100644 Binary files a/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-upload-binary.png and b/images/docs/fastedge/getting-started/create-fastedge-apps/http-apps-upload-binary.png differ diff --git a/images/docs/fastedge/getting-started/create-fastedge-apps/template-deploy-env-vars-form.png b/images/docs/fastedge/getting-started/create-fastedge-apps/template-deploy-env-vars-form.png new file mode 100644 index 000000000..0a9c715bb Binary files /dev/null and b/images/docs/fastedge/getting-started/create-fastedge-apps/template-deploy-env-vars-form.png differ diff --git a/images/docs/fastedge/getting-started/create-fastedge-apps/test-http-app.png b/images/docs/fastedge/getting-started/create-fastedge-apps/test-http-app.png deleted file mode 100644 index dd7d3bf35..000000000 Binary files a/images/docs/fastedge/getting-started/create-fastedge-apps/test-http-app.png and /dev/null differ diff --git a/images/docs/fastedge/getting-started/create-fastedge-apps/upload-binary-dialog.png b/images/docs/fastedge/getting-started/create-fastedge-apps/upload-binary-dialog.png deleted file mode 100644 index 6eba203ba..000000000 Binary files a/images/docs/fastedge/getting-started/create-fastedge-apps/upload-binary-dialog.png and /dev/null differ diff --git a/images/docs/fastedge/getting-started/get-started-cdn/cdn-apps-create-options.png b/images/docs/fastedge/getting-started/get-started-cdn/cdn-apps-create-options.png new file mode 100644 index 000000000..31ac27f80 Binary files /dev/null and b/images/docs/fastedge/getting-started/get-started-cdn/cdn-apps-create-options.png differ diff --git a/images/docs/fastedge/getting-started/get-started-cdn/cdn-apps-list.png b/images/docs/fastedge/getting-started/get-started-cdn/cdn-apps-list.png new file mode 100644 index 000000000..fd1c772b4 Binary files /dev/null and b/images/docs/fastedge/getting-started/get-started-cdn/cdn-apps-list.png differ diff --git a/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/actions-edit-app-from-template.png b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/actions-edit-app-from-template.png new file mode 100644 index 000000000..aafb396c7 Binary files /dev/null and b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/actions-edit-app-from-template.png differ diff --git a/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/actions-edit-app.png b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/actions-edit-app.png new file mode 100644 index 000000000..3fbbdf02f Binary files /dev/null and b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/actions-edit-app.png differ diff --git a/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-app-created.png b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-app-created.png new file mode 100644 index 000000000..1dbc4a212 Binary files /dev/null and b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-app-created.png differ diff --git a/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-app-from-template-setup.png b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-app-from-template-setup.png new file mode 100644 index 000000000..256d3ac82 Binary files /dev/null and b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-app-from-template-setup.png differ diff --git a/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-app-setup.png b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-app-setup.png new file mode 100644 index 000000000..004153699 Binary files /dev/null and b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-app-setup.png differ diff --git a/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-apps-page-create-app.png b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-apps-page-create-app.png new file mode 100644 index 000000000..adcc83ba0 Binary files /dev/null and b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-apps-page-create-app.png differ diff --git a/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-apps-upload-binary.png b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-apps-upload-binary.png new file mode 100644 index 000000000..aa2d79e37 Binary files /dev/null and b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-apps-upload-binary.png differ diff --git a/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-1.png b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-1.png new file mode 100644 index 000000000..d3729496b Binary files /dev/null and b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-1.png differ diff --git a/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-2.png b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-2.png new file mode 100644 index 000000000..4ebc96369 Binary files /dev/null and b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-fast-edge-2.png differ diff --git a/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-resource-settings-button.png b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-resource-settings-button.png new file mode 100644 index 000000000..c1cc46d12 Binary files /dev/null and b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-resource-settings-button.png differ diff --git a/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-settings-rules-section.png b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-settings-rules-section.png new file mode 100644 index 000000000..a5582c60b Binary files /dev/null and b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/cdn-settings-rules-section.png differ diff --git a/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/confirm-deletion.png b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/confirm-deletion.png new file mode 100644 index 000000000..4481184d7 Binary files /dev/null and b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/confirm-deletion.png differ diff --git a/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/remove-app-fstedge.png b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/remove-app-fstedge.png new file mode 100644 index 000000000..9cb835df5 Binary files /dev/null and b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/remove-app-fstedge.png differ diff --git a/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/rule-options-fastedge-app-enable.png b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/rule-options-fastedge-app-enable.png new file mode 100644 index 000000000..6784ff576 Binary files /dev/null and b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/rule-options-fastedge-app-enable.png differ diff --git a/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/upload-binary-dialog.png b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/upload-binary-dialog.png new file mode 100644 index 000000000..f1702e71e Binary files /dev/null and b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/upload-binary-dialog.png differ diff --git a/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/validate-jwt.png b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/validate-jwt.png new file mode 100644 index 000000000..b2a6bac70 Binary files /dev/null and b/images/docs/fastedge/getting-started/integrate-cdn-with-fastedge/validate-jwt.png differ diff --git a/images/docs/fastedge/kv-stores/bloom-filter/edit-bloom-store.png b/images/docs/fastedge/kv-stores/bloom-filter/edit-bloom-store.png index 3edeb4753..7c9a2f2c3 100644 Binary files a/images/docs/fastedge/kv-stores/bloom-filter/edit-bloom-store.png and b/images/docs/fastedge/kv-stores/bloom-filter/edit-bloom-store.png differ diff --git a/images/docs/fastedge/kv-stores/bloom-filter/insert-bloom-values.png b/images/docs/fastedge/kv-stores/bloom-filter/insert-bloom-values.png index 09e55e375..d5e7c04d5 100644 Binary files a/images/docs/fastedge/kv-stores/bloom-filter/insert-bloom-values.png and b/images/docs/fastedge/kv-stores/bloom-filter/insert-bloom-values.png differ diff --git a/images/docs/fastedge/kv-stores/bloom-filter/insert-bloom.png b/images/docs/fastedge/kv-stores/bloom-filter/insert-bloom.png index f0e2930aa..bb0033156 100644 Binary files a/images/docs/fastedge/kv-stores/bloom-filter/insert-bloom.png and b/images/docs/fastedge/kv-stores/bloom-filter/insert-bloom.png differ diff --git a/images/docs/fastedge/kv-stores/manage-kv-store/byod-store.png b/images/docs/fastedge/kv-stores/manage-kv-store/byod-store.png deleted file mode 100644 index 00852efd5..000000000 Binary files a/images/docs/fastedge/kv-stores/manage-kv-store/byod-store.png and /dev/null differ diff --git a/images/docs/fastedge/kv-stores/manage-kv-store/create-bloom.png b/images/docs/fastedge/kv-stores/manage-kv-store/create-bloom.png deleted file mode 100644 index 0e63d19f6..000000000 Binary files a/images/docs/fastedge/kv-stores/manage-kv-store/create-bloom.png and /dev/null differ diff --git a/images/docs/fastedge/kv-stores/manage-kv-store/create-zset.png b/images/docs/fastedge/kv-stores/manage-kv-store/create-zset.png deleted file mode 100644 index 32b9bdaac..000000000 Binary files a/images/docs/fastedge/kv-stores/manage-kv-store/create-zset.png and /dev/null differ diff --git a/images/docs/fastedge/kv-stores/manage-kv-store/edit-bloom-filter.png b/images/docs/fastedge/kv-stores/manage-kv-store/edit-bloom-filter.png deleted file mode 100644 index 35b0920f4..000000000 Binary files a/images/docs/fastedge/kv-stores/manage-kv-store/edit-bloom-filter.png and /dev/null differ diff --git a/images/docs/fastedge/kv-stores/manage-kv-store/edit-bloom-store.png b/images/docs/fastedge/kv-stores/manage-kv-store/edit-bloom-store.png deleted file mode 100644 index 3edeb4753..000000000 Binary files a/images/docs/fastedge/kv-stores/manage-kv-store/edit-bloom-store.png and /dev/null differ diff --git a/images/docs/fastedge/kv-stores/manage-kv-store/edit-zset-store.png b/images/docs/fastedge/kv-stores/manage-kv-store/edit-zset-store.png deleted file mode 100644 index a195450ee..000000000 Binary files a/images/docs/fastedge/kv-stores/manage-kv-store/edit-zset-store.png and /dev/null differ diff --git a/images/docs/fastedge/kv-stores/manage-kv-store/insert-bloom-values.png b/images/docs/fastedge/kv-stores/manage-kv-store/insert-bloom-values.png deleted file mode 100644 index 09e55e375..000000000 Binary files a/images/docs/fastedge/kv-stores/manage-kv-store/insert-bloom-values.png and /dev/null differ diff --git a/images/docs/fastedge/kv-stores/manage-kv-store/insert-bloom.png b/images/docs/fastedge/kv-stores/manage-kv-store/insert-bloom.png deleted file mode 100644 index f0e2930aa..000000000 Binary files a/images/docs/fastedge/kv-stores/manage-kv-store/insert-bloom.png and /dev/null differ diff --git a/images/docs/fastedge/kv-stores/manage-kv-store/insert-zset-values.png b/images/docs/fastedge/kv-stores/manage-kv-store/insert-zset-values.png deleted file mode 100644 index e8b63c29a..000000000 Binary files a/images/docs/fastedge/kv-stores/manage-kv-store/insert-zset-values.png and /dev/null differ diff --git a/images/docs/fastedge/kv-stores/manage-kv-store/insert-zset.png b/images/docs/fastedge/kv-stores/manage-kv-store/insert-zset.png deleted file mode 100644 index 769dfe2f5..000000000 Binary files a/images/docs/fastedge/kv-stores/manage-kv-store/insert-zset.png and /dev/null differ diff --git a/images/docs/fastedge/kv-stores/sorted-set/edit-zset-store.png b/images/docs/fastedge/kv-stores/sorted-set/edit-zset-store.png index a195450ee..01aa3de22 100644 Binary files a/images/docs/fastedge/kv-stores/sorted-set/edit-zset-store.png and b/images/docs/fastedge/kv-stores/sorted-set/edit-zset-store.png differ diff --git a/images/docs/fastedge/kv-stores/sorted-set/insert-zset-values.png b/images/docs/fastedge/kv-stores/sorted-set/insert-zset-values.png index e8b63c29a..257613dc4 100644 Binary files a/images/docs/fastedge/kv-stores/sorted-set/insert-zset-values.png and b/images/docs/fastedge/kv-stores/sorted-set/insert-zset-values.png differ diff --git a/images/docs/fastedge/kv-stores/sorted-set/insert-zset.png b/images/docs/fastedge/kv-stores/sorted-set/insert-zset.png index 769dfe2f5..c4d6b756b 100644 Binary files a/images/docs/fastedge/kv-stores/sorted-set/insert-zset.png and b/images/docs/fastedge/kv-stores/sorted-set/insert-zset.png differ diff --git a/images/docs/fastedge/manage-apps/app-management-page-annotated.png b/images/docs/fastedge/manage-apps/app-management-page-annotated.png index d210268f9..25a0d2cc6 100644 Binary files a/images/docs/fastedge/manage-apps/app-management-page-annotated.png and b/images/docs/fastedge/manage-apps/app-management-page-annotated.png differ diff --git a/images/docs/fastedge/manage-apps/env-vars.png b/images/docs/fastedge/manage-apps/env-vars.png index f5d1a68af..f9e551778 100644 Binary files a/images/docs/fastedge/manage-apps/env-vars.png and b/images/docs/fastedge/manage-apps/env-vars.png differ diff --git a/images/docs/fastedge/manage-apps/manage-apps-menu.png b/images/docs/fastedge/manage-apps/manage-apps-menu.png index f9c12b889..9806b2a6d 100644 Binary files a/images/docs/fastedge/manage-apps/manage-apps-menu.png and b/images/docs/fastedge/manage-apps/manage-apps-menu.png differ diff --git a/images/docs/fastedge/manage-apps/response-headers.png b/images/docs/fastedge/manage-apps/response-headers.png index f8837bb5c..3e6568db0 100644 Binary files a/images/docs/fastedge/manage-apps/response-headers.png and b/images/docs/fastedge/manage-apps/response-headers.png differ diff --git a/images/docs/fastedge/manage-apps/secrets.png b/images/docs/fastedge/manage-apps/secrets.png index 71514b417..9097b2140 100644 Binary files a/images/docs/fastedge/manage-apps/secrets.png and b/images/docs/fastedge/manage-apps/secrets.png differ diff --git a/images/docs/fastedge/manage-apps/stop-app.png b/images/docs/fastedge/manage-apps/stop-app.png index 78b23b020..1ff13d907 100644 Binary files a/images/docs/fastedge/manage-apps/stop-app.png and b/images/docs/fastedge/manage-apps/stop-app.png differ diff --git a/images/docs/fastedge/manage-apps/storage.png b/images/docs/fastedge/manage-apps/storage.png index 6b6932a22..788ba7cd7 100644 Binary files a/images/docs/fastedge/manage-apps/storage.png and b/images/docs/fastedge/manage-apps/storage.png differ diff --git a/images/docs/fastedge/manage-apps/view-logging.png b/images/docs/fastedge/manage-apps/view-logging.png index 08f31d8e1..29d6f40a5 100644 Binary files a/images/docs/fastedge/manage-apps/view-logging.png and b/images/docs/fastedge/manage-apps/view-logging.png differ diff --git a/images/docs/fastedge/secret-manager/add-secret.png b/images/docs/fastedge/secret-manager/add-secret.png deleted file mode 100644 index 961757079..000000000 Binary files a/images/docs/fastedge/secret-manager/add-secret.png and /dev/null differ diff --git a/images/docs/fastedge/secret-manager/create-secret.png b/images/docs/fastedge/secret-manager/create-secret.png deleted file mode 100644 index 50fab56a5..000000000 Binary files a/images/docs/fastedge/secret-manager/create-secret.png and /dev/null differ diff --git a/images/docs/fastedge/secret-manager/delete-detachment.png b/images/docs/fastedge/secret-manager/delete-detachment.png deleted file mode 100644 index e0a1fcce7..000000000 Binary files a/images/docs/fastedge/secret-manager/delete-detachment.png and /dev/null differ diff --git a/images/docs/fastedge/secret-manager/delete-list.png b/images/docs/fastedge/secret-manager/delete-list.png deleted file mode 100644 index ec799c96d..000000000 Binary files a/images/docs/fastedge/secret-manager/delete-list.png and /dev/null differ diff --git a/images/docs/fastedge/secret-manager/edit-secret.png b/images/docs/fastedge/secret-manager/edit-secret.png deleted file mode 100644 index 65fda58bc..000000000 Binary files a/images/docs/fastedge/secret-manager/edit-secret.png and /dev/null differ diff --git a/images/docs/fastedge/secret-manager/secret-list.png b/images/docs/fastedge/secret-manager/secret-list.png deleted file mode 100644 index 3c96c1a6e..000000000 Binary files a/images/docs/fastedge/secret-manager/secret-list.png and /dev/null differ diff --git a/images/docs/fastedge/secret-manager/slots-example-indices.png b/images/docs/fastedge/secret-manager/slots-example-indices.png deleted file mode 100644 index 6530c2614..000000000 Binary files a/images/docs/fastedge/secret-manager/slots-example-indices.png and /dev/null differ diff --git a/images/docs/fastedge/secret-manager/slots-example-timestamps.png b/images/docs/fastedge/secret-manager/slots-example-timestamps.png deleted file mode 100644 index 39fa5f586..000000000 Binary files a/images/docs/fastedge/secret-manager/slots-example-timestamps.png and /dev/null differ diff --git a/images/docs/fastedge/secrets-manager/create-secret-form.png b/images/docs/fastedge/secrets-manager/create-secret-form.png new file mode 100644 index 000000000..ca28abd05 Binary files /dev/null and b/images/docs/fastedge/secrets-manager/create-secret-form.png differ diff --git a/images/docs/fastedge/secrets-manager/manage-secrets/create-secret-encrypted.png b/images/docs/fastedge/secrets-manager/manage-secrets/create-secret-encrypted.png new file mode 100644 index 000000000..244b10b99 Binary files /dev/null and b/images/docs/fastedge/secrets-manager/manage-secrets/create-secret-encrypted.png differ diff --git a/images/docs/fastedge/secrets-manager/manage-secrets/delete-secret-confirm.png b/images/docs/fastedge/secrets-manager/manage-secrets/delete-secret-confirm.png new file mode 100644 index 000000000..030f32e3b Binary files /dev/null and b/images/docs/fastedge/secrets-manager/manage-secrets/delete-secret-confirm.png differ diff --git a/images/docs/fastedge/secrets-manager/manage-secrets/delete-secret-menu.png b/images/docs/fastedge/secrets-manager/manage-secrets/delete-secret-menu.png new file mode 100644 index 000000000..ea561a564 Binary files /dev/null and b/images/docs/fastedge/secrets-manager/manage-secrets/delete-secret-menu.png differ diff --git a/images/docs/fastedge/secrets-manager/manage-secrets/edit-secret-form.png b/images/docs/fastedge/secrets-manager/manage-secrets/edit-secret-form.png new file mode 100644 index 000000000..bf231a7b1 Binary files /dev/null and b/images/docs/fastedge/secrets-manager/manage-secrets/edit-secret-form.png differ diff --git a/images/docs/fastedge/secrets-manager/manage-secrets/secrets-list-with-item.png b/images/docs/fastedge/secrets-manager/manage-secrets/secrets-list-with-item.png new file mode 100644 index 000000000..ff42a97c6 Binary files /dev/null and b/images/docs/fastedge/secrets-manager/manage-secrets/secrets-list-with-item.png differ diff --git a/images/docs/fastedge/secrets-manager/manage-secrets/secrets-list.png b/images/docs/fastedge/secrets-manager/manage-secrets/secrets-list.png new file mode 100644 index 000000000..13a4453d6 Binary files /dev/null and b/images/docs/fastedge/secrets-manager/manage-secrets/secrets-list.png differ diff --git a/images/docs/fastedge/secrets-manager/slots/slots-example-indices.png b/images/docs/fastedge/secrets-manager/slots/slots-example-indices.png new file mode 100644 index 000000000..681db9350 Binary files /dev/null and b/images/docs/fastedge/secrets-manager/slots/slots-example-indices.png differ diff --git a/images/docs/fastedge/secrets-manager/slots/slots-example-timestamps.png b/images/docs/fastedge/secrets-manager/slots/slots-example-timestamps.png new file mode 100644 index 000000000..6a5dd3572 Binary files /dev/null and b/images/docs/fastedge/secrets-manager/slots/slots-example-timestamps.png differ diff --git a/llms-full.txt b/llms-full.txt index 8951d0ce0..8d775abf8 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -1,6 +1,6 @@ # Gcore Docs - Full Index -> Complete article index across all Gcore products. 580 articles. +> Complete article index across all Gcore products. 586 articles. > Use this file for offline indexing, bulk vectorization, or large-context retrieval. # Gcore Account settings @@ -123,7 +123,7 @@ - [Integrate CDN resource with WordPress (WP SuperCache plugin)](https://gcore.com/docs/cdn/getting-started/integrate-cdn-with-cms/wordpress/integrate-cdn-resource-with-wordpress-wp-supercache-plugin.md): Configure WP Super Cache plugin CDN integration by enabling CDN Support, entering Gcore CDN CNAME in Off-site URL field, and verifying static asset URLs are rewritten to the custom domain. - [Integrate CDN resource with X-Cart](https://gcore.com/docs/cdn/getting-started/integrate-cdn-with-cms/integrate-cdn-resource-with-x-cart.md): Configure Gcore CDN resource integration with X-Cart 4.4.x by setting CNAME record in Customer Portal and modifying smarty.php, func.files.php, function.get_category_image_url.php, and banner_rotator.tpl files to rewrite static asset URLs to CDN CNAME domain. - [Integrate CDN resource with XenForo](https://gcore.com/docs/cdn/getting-started/integrate-cdn-with-cms/integrate-cdn-resource-with-xenforo.md): Configure Gcore CDN resource integration with XenForo by editing config.php, updating Style General Settings with CDN CNAME domain, and verifying static file URLs are rewritten to the configured CNAME record. -- [Extend CDN functionality with FastEdge](https://gcore.com/docs/cdn/getting-started/integrate-cdn-with-fastedge.md): Deploy FastEdge serverless compute functions at CDN edge locations to extend content delivery with custom request/response processing, origin shielding, and dynamic content generation. +- [Extend CDN functionality with FastEdge](https://gcore.com/docs/cdn/getting-started/integrate-cdn-with-fastedge.md): Integrate FastEdge CDN applications with a Gcore CDN resource to add custom request and response processing via Customer Portal or REST API. ## Configure an origin - [Add CDN servers to the origin ACL whitelist](https://gcore.com/docs/cdn/getting-started/configure-an-origin/add-cdn-servers-to-the-origin-acl-whitelist.md): Configure origin ACL whitelist for CDN servers using HTTP headers, IP addresses, or subnets via API endpoints; HTTP header method recommended to avoid manual updates as CDN server IPs change every 30-60 minutes. @@ -252,37 +252,45 @@ # Gcore FastEdge -> Deploy WebAssembly edge applications on Gcore CDN edge nodes using FastEdge serverless compute for HTTP request processing, A/B testing, image conversion, and custom edge logic. +> FastEdge is a serverless WebAssembly edge compute platform. Run Rust and JavaScript applications at every Gcore edge location — HTTP apps, CDN extensions, edge storage, secrets, and cache available at runtime. -- [FastEdge](https://gcore.com/docs/fastedge.md): Deploy WebAssembly edge applications on Gcore CDN edge nodes using FastEdge serverless compute for HTTP request processing, A/B testing, image conversion, and custom edge logic. -- [FastEdge overview](https://gcore.com/docs/fastedge/getting-started.md): Deploy WebAssembly applications on Gcore's global edge network using FastEdge for serverless execution with HTTP request/response modification, A/B testing, personalization, image conversion, and custom DNS resolving without infrastructure maintenance. +- [FastEdge](https://gcore.com/docs/fastedge.md): FastEdge is a serverless WebAssembly edge compute platform. Run Rust and JavaScript applications at every Gcore edge location — HTTP apps, CDN extensions, edge storage, secrets, and cache available at runtime. -## Create apps -- [Create FastEdge apps](https://gcore.com/docs/fastedge/create-apps.md): Create FastEdge HTTP and CDN applications using Rust SDK, JavaScript SDK, or Proxy-Wasm spec to run serverless code on Gcore's CDN network with custom URLs and request/response processing. +## Get started +- [FastEdge overview](https://gcore.com/docs/fastedge/getting-started.md): Overview of FastEdge serverless WebAssembly execution on Gcore edge network - HTTP Applications, CDN Applications, use cases including A/B testing, personalization, authentication, and image manipulation. +- [Set up Rust for FastEdge](https://gcore.com/docs/fastedge/getting-started/setup-rust-modern.md): Set up Rust for FastEdge HTTP applications using wstd and wasm32-wasip2, add the WebAssembly target, configure Cargo.toml with the wstd dependency, and verify the toolchain compiles successfully. +- [Set up Rust for FastEdge](https://gcore.com/docs/fastedge/getting-started/setup-rust-legacy.md): Set up the FastEdge Legacy Rust SDK using the fastedge crate and wasm32-wasip1, add the WebAssembly target, configure Cargo.toml, and verify the toolchain compiles a FastEdge application. +- [Set up JavaScript for FastEdge](https://gcore.com/docs/fastedge/getting-started/setup-javascript.md): Set up the FastEdge JavaScript SDK, install Node.js v22 or higher, install the fastedge-sdk-js package, configure a project, and verify the toolchain compiles a FastEdge application to WebAssembly. +- [Set up Rust for FastEdge CDN apps](https://gcore.com/docs/fastedge/getting-started/setup-rust-cdn.md): Set up Rust for FastEdge CDN applications using the proxy-wasm crate and wasm32-wasip1, add the WebAssembly target, configure Cargo.toml, and verify the toolchain compiles a CDN filter. + +## Applications ## HTTP Applications -- [Create FastEdge HTTP applications](https://gcore.com/docs/fastedge/getting-started/create-fastedge-apps.md): Create FastEdge HTTP applications by uploading custom WebAssembly binaries built with JavaScript SDK or Rust SDK, or by deploying preconfigured templates via Gcore Customer Portal or API. -- [Built-in HTTP application templates](https://gcore.com/docs/fastedge/built-in-templates.md): Step-by-step guide for deploying FastEdge built-in HTTP application templates — Markdown renderer and Geolocation-based redirect — including environment variable configuration, real-world examples, and testing. -- [Build Rust WASI-HTTP apps](https://gcore.com/docs/fastedge/getting-started/build-a-rust-wasi-app.md): Build FastEdge Rust applications using the WASI-HTTP interface - from a hello-world component that verifies the toolchain to an app that fetches and shapes data from an external API. +- [Create FastEdge HTTP applications](https://gcore.com/docs/fastedge/getting-started/create-fastedge-apps.md): Create FastEdge HTTP applications by uploading custom WebAssembly binaries built with JavaScript SDK or Rust SDK, or by deploying preconfigured templates via Gcore Customer Portal or REST API. +- [Render Markdown at the edge](https://gcore.com/docs/fastedge/render-markdown.md): Deploy the FastEdge Markdown renderer template to fetch Markdown files from a remote URL and return them as rendered HTML pages via the Customer Portal. +- [Redirect visitors by location](https://gcore.com/docs/fastedge/geolocation-redirect.md): Deploy the FastEdge geolocation redirect template to route visitors to region-specific URLs based on their country via the Customer Portal. +- [Build a FastEdge HTTP application](https://gcore.com/docs/fastedge/getting-started/get-started-http.md): Build and deploy a FastEdge HTTP application in Modern Rust, Legacy Rust, or JavaScript via Customer Portal or REST API. +- [Call an external API from a FastEdge app](https://gcore.com/docs/fastedge/getting-started/call-external-api-rust.md): Build and deploy a FastEdge application in Modern Rust, Legacy Rust, or JavaScript that makes outbound HTTP requests, fetches data from a REST API, and returns shaped JSON via Customer Portal or REST API. ## CDN Applications -- [Extend CDN functionality with FastEdge](https://gcore.com/docs/fastedge/getting-started/integrate-cdn-with-fastedge.md): Deploy FastEdge serverless compute functions at CDN edge locations to extend content delivery with custom request/response logic, origin shielding, and dynamic content transformation. -- [CDN properties](https://gcore.com/docs/fastedge/getting-started/cdn-properties.md): Access and modify HTTP request and response properties in Gcore CDN Proxy-Wasm applications via read-write properties like path, host, queryString and read-only properties like scheme, method, country, city, ASN, latitude, longitude, region, continent deciphered from client IP. -- [Manage FastEdge apps](https://gcore.com/docs/fastedge/manage-apps.md): Manage FastEdge HTTP and CDN applications via the Customer Portal - start or stop applications, view metrics and logs, configure response headers, environment variables, secrets, and Edge Storage key-value storage. -- [Create and manage templates](https://gcore.com/docs/fastedge/create-manage-templates.md): Create FastEdge templates with custom binary files, mandatory parameters, and Secret environment variables for HTTP and CDN applications via Customer Portal. +- [Extend CDN functionality with FastEdge](https://gcore.com/docs/fastedge/getting-started/integrate-cdn-with-fastedge.md): Integrate FastEdge CDN applications with a Gcore CDN resource to add custom request and response processing via Customer Portal or REST API. +- [Build and deploy a FastEdge CDN application](https://gcore.com/docs/fastedge/getting-started/get-started-cdn.md): Build and deploy a FastEdge CDN application in Rust using Proxy-Wasm via Customer Portal or REST API. +- [Request and response properties](https://gcore.com/docs/fastedge/getting-started/cdn-properties.md): Reference for HTTP request and response properties available in FastEdge CDN Proxy-Wasm applications. Covers get_property and set_property paths, access modes per hook, and custom properties for passing state within a processing phase. +- [Manage FastEdge apps](https://gcore.com/docs/fastedge/manage-apps.md): Manage FastEdge HTTP and CDN application lifecycle, metrics, logs, and configuration via Customer Portal or REST API. +- [Create and manage templates](https://gcore.com/docs/fastedge/create-manage-templates.md): Create, edit, delete, and update FastEdge templates for HTTP and CDN applications via the Customer Portal or REST API — including binary upload, mandatory parameters, secret environment variables, and creating apps from templates. ## Secrets Manager -- [Secrets Manager](https://gcore.com/docs/fastedge/secrets-manager/manage-secrets.md): Create and manage encrypted secrets in FastEdge Secrets Manager with slot numbers and secret values, then access them in applications via JavaScript SDK and Rust SDK. -- [Secrets Slots](https://gcore.com/docs/fastedge/secrets-manager/slots.md): Configure FastEdge Secrets Slots for secret rotation by storing multiple encrypted secret versions with slot indices, enabling runtime secret updates via get_secret API without deleting old values and supporting token validation against specific secret versions using slot indices or timestamps. +- [Secrets Manager](https://gcore.com/docs/fastedge/secrets-manager/manage-secrets.md): Create, edit, and delete encrypted secrets in FastEdge Secrets Manager via the Customer Portal or REST API, then link secrets to applications that read them at runtime. +- [Secret rotation with slots](https://gcore.com/docs/fastedge/secrets-manager/slots.md): Use FastEdge Secrets Manager slots to implement secret rotation — each slot stores a separate encrypted value identified by a numeric index or Unix timestamp, enabling runtime rotation without application redeployment. ## Edge Storage -- [How it works](https://gcore.com/docs/fastedge/kv-stores/how-it-works.md): Deploy Edge Storage as a distributed key-value store co-located with FastEdge WASM applications at every global edge location, providing sub-millisecond read latency with write-once replication to central SQL database and eventual consistency propagation within 1-2 seconds. +- [How it works](https://gcore.com/docs/fastedge/kv-stores/how-it-works.md): Understand how Edge Storage co-locates a key-value store with FastEdge applications at every edge location for sub-millisecond reads, with writes persisted via REST API to a central database and replicated globally within 1-2 seconds. - [Edge Storage](https://gcore.com/docs/fastedge/kv-stores/manage-kv-store.md): Create and manage FastEdge Edge Storage stores and key-value pairs via Customer Portal or via the FastEdge REST API. -- [Sorted Set](https://gcore.com/docs/fastedge/kv-stores/sorted-set.md): Create and manage Sorted Sets (ZSET) in FastEdge Edge Storage via the Gcore Customer Portal, adding members with numeric scores that are automatically ordered for leaderboards and priority-based lists. -- [Bloom Filter](https://gcore.com/docs/fastedge/kv-stores/bloom-filter.md): Create and manage Bloom Filters in FastEdge Edge Storage via Gcore Customer Portal to test set membership with space-efficient probabilistic data structures supporting manual value entry and file uploads up to 1 MB. +- [Sorted Set](https://gcore.com/docs/fastedge/kv-stores/sorted-set.md): Create and manage Sorted Sets (ZSET) in FastEdge Edge Storage via the Gcore Customer Portal or the FastEdge REST API. Sorted sets store unique members with numeric scores ordered for leaderboards, rankings, and priority-based lists. +- [Bloom Filter](https://gcore.com/docs/fastedge/kv-stores/bloom-filter.md): Create and manage Bloom Filters in FastEdge Edge Storage via the Gcore Customer Portal or the FastEdge REST API. Bloom filters are space-efficient probabilistic structures that test set membership and support only append operations — individual values cannot be removed once added. - [Cache](https://gcore.com/docs/fastedge/cache.md): Cache is a POP-local, strongly consistent key-value store available to FastEdge applications at runtime for transient state such as rate-limit counters, response memoization, and idempotency checks. It is distinct from Edge Storage, which is globally replicated and durable. -- [Troubleshooting](https://gcore.com/docs/fastedge/troubleshooting.md): Diagnose FastEdge application failures using HTTP status codes 530 (internal error), 531 (memory limit exceeded), 532 (timeout), and 533 (crash) to identify root causes and access FastEdge SDK Rust, JavaScript, AssemblyScript, and development tools for resolution. -- [FastEdge CLI](https://gcore.com/docs/fastedge/fastedge-cli.md): Install FastEdge CLI from the FastEdge-lib repository, build the Rust-based tool, and execute local HTTP applications with commands supporting environment variables, geo headers, and request/response inspection. +- [Troubleshooting](https://gcore.com/docs/fastedge/troubleshooting.md): Diagnose FastEdge application failures using HTTP status codes 530 (initialization failed), 531 (runtime error), 532 (timeout), and 533 (memory limit exceeded). Includes debug logging via API, platform limits, and SDK-specific notes for Rust and JavaScript. +- [FastEdge CLI](https://gcore.com/docs/fastedge/fastedge-cli.md): Install fastedge-run to test FastEdge Wasm applications locally before deploying. Available as a pre-built binary for macOS, Linux, and Windows, or bundled with the FastEdge VS Code extension. Supports HTTP server mode, environment variables, and geo header simulation. --- # Gcore Edge Cloud diff --git a/llms.txt b/llms.txt index 749a35d73..4c6d8b963 100644 --- a/llms.txt +++ b/llms.txt @@ -10,7 +10,7 @@ - [Account settings](https://gcore.com/docs/account-settings/llms.txt): Configure Gcore Customer Portal account settings including user profile, two-factor authentication, billing, payments, user roles and permissions, API tokens, notifications, and support access (25 articles). - [Developer Tools](https://gcore.com/docs/developer-tools/llms.txt): REST API, SDKs, MCP Server, Terraform (24 articles). - [CDN](https://gcore.com/docs/cdn/llms.txt): Configure Gcore CDN resources for content delivery including origin groups, caching rules, SSL certificates, HTTP headers, cache purge, logs, Grafana dashboards, and Terraform integration (119 articles). -- [FastEdge](https://gcore.com/docs/fastedge/llms.txt): Deploy WebAssembly edge applications on Gcore CDN edge nodes using FastEdge serverless compute for HTTP request processing, A/B testing, image conversion, and custom edge logic (19 articles). +- [FastEdge](https://gcore.com/docs/fastedge/llms.txt): FastEdge is a serverless WebAssembly edge compute platform. Run Rust and JavaScript applications at every Gcore edge location — HTTP apps, CDN extensions, edge storage, secrets, and cache available at runtime (25 articles). - [Edge Cloud](https://gcore.com/docs/cloud/llms.txt): Provision Gcore Edge Cloud resources including Virtual Machines, Bare Metal servers, managed Kubernetes, PostgreSQL, object storage, load balancers, and networking across global regions (104 articles). - [AI](https://gcore.com/docs/edge-ai/llms.txt): Deploy AI inference and GPU-accelerated training using Gcore AI products - Everywhere Inference for low-latency model serving at the edge and GPU Cloud for Bare Metal and Virtual Machine compute (26 articles). - [Gclaw](https://gcore.com/docs/gclaw/llms.txt): Managed OpenClaw service with built-in inference for launching AI agents instantly (10 articles).