Skip to main content

Overview

FastEdge applications combine a WebAssembly binary with configuration, environment variables, and secrets for deployment at the CDN edge. Apps can be in various states (draft, enabled, disabled) and support debugging, logging, and custom response headers.

Create App

Add a new FastEdge application.
package main

import (
    "context"
    "fmt"
    "github.com/G-Core/gcore-go"
    "github.com/G-Core/gcore-go/fastedge"
    "github.com/G-Core/gcore-go/option"
)

func main() {
    client := gcore.NewClient(
        option.WithAPIKey("your-api-key"),
    )
    
    app, err := client.Fastedge.Apps.New(context.Background(), fastedge.AppNewParams{
        App: fastedge.AppParam{
            Name:     gcore.String("my-edge-app"),
            Binary:   gcore.Int(12345),
            Comment:  gcore.String("My FastEdge application"),
            Status:   gcore.Int(1),
            Template: gcore.Int(1),
            Debug:    gcore.Bool(false),
            Log:      fastedge.AppLogKafka,
            Env: map[string]string{
                "API_ENDPOINT": "https://api.example.com",
                "CACHE_TTL":    "3600",
            },
            RspHeaders: map[string]string{
                "X-Custom-Header": "value",
            },
            Secrets: map[string]fastedge.AppSecretParam{
                "api_key": {
                    ID: 123,
                },
            },
            Stores: map[string]fastedge.AppStoreParam{
                "cache": {
                    ID: 456,
                },
            },
        },
    })
    
    if err != nil {
        panic(err)
    }
    
    fmt.Printf("Created app ID: %d\n", app.ID)
    fmt.Printf("App URL: %s\n", app.URL)
}

Parameters

name
string
Application name
binary
int64
Binary ID - references a WebAssembly binary to use
comment
string
Application description or comment
status
int64
Status code:
  • 0 - draft (inactive)
  • 1 - enabled
  • 2 - disabled
template
int64
Template ID to use for the application
debug
bool
Switch on logging for 30 minutes (switched off by default)
log
string
Logging channel. Options: kafka (default, allows exploring logs with API), none
env
map[string]string
Environment variables as key-value pairs
rsp_headers
map[string]string
Extra headers to add to responses
secrets
map[string]AppSecretParam
Application secrets mapping. Each entry contains:
  • id (int64, required) - The unique identifier of the secret
stores
map[string]AppStoreParam
Application edge stores mapping. Each entry contains:
  • id (int64, required) - The identifier of the store

Response

Returns an AppShort object with the created application details.
id
int64
required
Application ID
name
string
required
Application name
binary
int64
required
Binary ID
status
int64
required
Application status code
url
string
Application URL for accessing the edge app
api_type
string
required
WebAssembly API type
plan_id
int64
required
Application plan ID
plan
string
Application plan name
comment
string
Description of the application
debug
bool
Whether debug mode is enabled
debug_until
time.Time
When debugging finishes (ISO 8601 format)
networks
[]string
List of networks the app is deployed to
template
int64
Template ID
template_name
string
Template name
upgradeable_to
int64
ID of the binary the app can be upgraded to

Get App Details

Retrieve detailed information about a specific application.
app, err := client.Fastedge.Apps.Get(context.Background(), 12345)
if err != nil {
    panic(err)
}

fmt.Printf("App Name: %s\n", app.Name)
fmt.Printf("Binary: %d\n", app.Binary)
fmt.Printf("Status: %d\n", app.Status)
fmt.Printf("URL: %s\n", app.URL)

Parameters

id
int64
required
The application ID

Response

Returns a full App object with all configuration details including environment variables, secrets, stores, and headers.
name
string
Application name
binary
int64
Binary ID
api_type
string
WebAssembly API type
status
int64
Status code
comment
string
Application description
debug
bool
Debug mode status
debug_until
time.Time
Debug expiration timestamp
log
string
Logging channel (kafka or none)
env
map[string]string
Environment variables
rsp_headers
map[string]string
Custom response headers
secrets
map[string]AppSecret
Application secrets with details
stores
map[string]AppStore
Application edge stores with details
plan
string
Plan name
plan_id
int64
Plan ID
template
int64
Template ID
template_name
string
Template name
url
string
Application URL
networks
[]string
Deployed networks

List Apps

List all applications for the client with optional filtering and pagination.
// List all apps
apps, err := client.Fastedge.Apps.List(context.Background(), fastedge.AppListParams{})
if err != nil {
    panic(err)
}

for _, app := range apps.Apps {
    fmt.Printf("App: %s (ID: %d)\n", app.Name, app.ID)
}

// List with filters
apps, err = client.Fastedge.Apps.List(context.Background(), fastedge.AppListParams{
    Status:   gcore.Int(1), // Only enabled apps
    Binary:   gcore.Int(12345),
    APIType:  fastedge.AppListParamsAPITypeWasiHTTP,
    Limit:    gcore.Int(50),
    Offset:   gcore.Int(0),
    Ordering: fastedge.AppListParamsOrderingName,
})

Query Parameters

name
string
Filter by application name
status
int64
Filter by status code (0-5)
binary
int64
Filter by binary ID
template
int64
Filter by template ID
plan
int64
Filter by plan ID
api_type
string
Filter by API type:
  • wasi-http - WASI with HTTP entry point
  • proxy-wasm - Proxy-Wasm app, callable from CDN
limit
int64
Maximum number of results (pagination)
offset
int64
Offset for pagination
ordering
string
Sort order. Options: name, -name, status, -status, id, -id, template, -template, binary, -binary, plan, -planUse - prefix for descending order

Response

Returns a paginated list of AppShort objects.

Auto-Paging

For convenience, you can use ListAutoPaging to automatically iterate through all pages:
pager := client.Fastedge.Apps.ListAutoPaging(context.Background(), fastedge.AppListParams{
    Status: gcore.Int(1),
})

for pager.Next() {
    app := pager.Current()
    fmt.Printf("App: %s\n", app.Name)
}

if err := pager.Err(); err != nil {
    panic(err)
}

Update App

Partially update an existing application (PATCH).
app, err := client.Fastedge.Apps.Update(
    context.Background(),
    12345, // app ID
    fastedge.AppUpdateParams{
        App: fastedge.AppParam{
            Status:  gcore.Int(1), // Enable the app
            Debug:   gcore.Bool(true),
            Comment: gcore.String("Updated description"),
            Env: map[string]string{
                "NEW_VAR": "new_value",
            },
        },
    },
)

Parameters

id
int64
required
The application ID
app
AppParam
Application fields to update. Only provided fields will be updated (partial update). Accepts the same parameters as the Create App endpoint.

Response

Returns the updated AppShort object.

Replace App

Fully replace an application’s configuration (PUT).
app, err := client.Fastedge.Apps.Replace(
    context.Background(),
    12345, // app ID
    fastedge.AppReplaceParams{
        Body: fastedge.AppReplaceParamsBody{
            AppParam: fastedge.AppParam{
                Name:     gcore.String("my-app"),
                Binary:   gcore.Int(67890),
                Status:   gcore.Int(1),
                Template: gcore.Int(1),
                // All required fields must be provided
            },
        },
    },
)

Parameters

id
int64
required
The application ID
app
AppParam
required
Complete application configuration. All fields should be provided for a full replacement.

Response

Returns the replaced AppShort object.

Delete App

Delete an application permanently.
err := client.Fastedge.Apps.Delete(context.Background(), 12345)
if err != nil {
    panic(err)
}

fmt.Println("App deleted successfully")

Parameters

id
int64
required
The application ID to delete

Response

Returns nil on success, or an error if the deletion fails.

Application Logs

Access application logs through the Logs sub-service. See the App Logs documentation for details.
// Access logs for an app
logs := client.Fastedge.Apps.Logs

API Types

FastEdge supports two WebAssembly API types:

WASI-HTTP

WASI with HTTP entry point - suitable for applications that need to handle HTTP requests directly.

Proxy-Wasm

Proxy-Wasm applications that can be called from the CDN layer, allowing integration with CDN features.

Best Practices

Development Workflow: Start with status 0 (draft) while developing, enable debug mode during testing, then set status to 1 (enabled) for production.
Debug mode automatically switches off after 30 minutes to prevent excessive log accumulation.
Environment variables and secrets are distinct - use secrets for sensitive values like API keys that should be stored securely.

Error Handling

app, err := client.Fastedge.Apps.Get(context.Background(), 12345)
if err != nil {
    var apiErr *gcore.Error
    if errors.As(err, &apiErr) {
        // Handle API error
        fmt.Printf("API Error: %s\n", apiErr.Error())
        // Access raw request/response for debugging
        fmt.Println(string(apiErr.DumpRequest(true)))
    }
    return
}

Build docs developers (and LLMs) love