1. Signatures
  2. Overview

Signatures are one of the core concepts behind Scale Functions.

They are used to define the inputs and outputs of a function using a declarative syntax we call the Scale Signature DSL, and once they are parsed by our compiler we are able to generated cross-language type safety.

We use the Polyglot library under the hood to facilitate efficient serialization and deserialization of structured data between host and guest languages and to cross the WASM boundary.

We also publish and support a number of Official Scale Signatures for common use cases:

SignatureDescriptionSupported LanguagesAvailable AdaptersLatest Version
HTTPHTTP Signature meant to be used for HTTP handlers and middleware.Go, Rust, TypeScript, JavaScriptnet/http, FastHTTP, NextJS0.3.6

Official are maintained by the Scale Functions team and come with Adapters which allow them to be used seamlessly from popular Frameworks and Libraries.

We are working on a way to allow users to publish their own Signatures! If you are interested in this feature, please join the #scale channel in our Discord and let us know!\

‚Äč
Chaining Functions

Scale Functions are designed to be chained together to form a pipeline of functions that can be executed sequentially.

To allow developers to make decisions about when the next function in the chain should be executed, all signatures provide a Next() method which runs the next function in the chain.

//go:build tinygo || js || wasm
package scale

import (
    signature "github.com/loopholelabs/scale-signature-http"
)

func Scale(ctx *signature.Context) (*signature.Context, error) {
    ctx.Response().SetBody("Hello, World!")
    return ctx.Next()
}

If there is no next function in the chain, the Next() method will not do anything and will return the same context.