Supabase.Functions (supabase_functions v0.1.0)
This module provides integration with the Supabase Edge Functions API, enabling developers to invoke their serverless functions.
Usage
iex> client = Supabase.init_client!("SUPABASE_URL", "SUPABASE_KEY")
iex> Supabase.Functions.invoke(client, "function_name", %{})
Summary
Functions
Invokes a function
Types
@type on_response() :: ({Supabase.Fetcher.status(), Supabase.Fetcher.headers(), body :: Enumerable.t()} -> Supabase.result(Supabase.Fetcher.Response.t()))
@type opt() :: {:body, Supabase.Fetcher.body()} | {:headers, Supabase.Fetcher.headers()} | {:method, Supabase.Fetcher.method()} | {:region, region()} | {:on_response, on_response()}
Available options for invoking a function:
body
: The body of the request.headers
: The additional custom headers of the request.method
: The HTTP method of the request.region
: The Region to invoke the function in.on_response
: The custom response handler for response streaming.
@type opts() :: Enumerable.t(opt())
@type region() ::
:any
| :"us-west-1"
| :"us-west-2"
| :"us-east-1"
| :"eu-west-1"
| :"eu-west-2"
| :"eu-west-3"
| :"ap-south-1"
| :"ap-southeast-1"
| :"ap-southeast-2"
| :"ap-northeast-1"
| :"ap-northeast-2"
| :"sa-east-1"
| :"ca-central-1"
| :"eu-central-1"
Functions
@spec invoke(Supabase.Client.t(), function :: String.t(), opts()) :: Supabase.result(Supabase.Fetcher.Response.t())
Invokes a function
Invoke a Supabase Edge Function.
- When you pass in a body to your function, we automatically attach the
Content-Type
header automatically. If it doesn't match any of these types we assume the payload is json, serialize it and attach theContent-Type
header asapplication/json
. You can override this behavior by passing in aContent-Type
header of your own. - Responses are automatically parsed as json depending on the Content-Type header sent by your function. Responses are parsed as text by default.