Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Error ¶
func Error(code StatusCode, format string, a ...interface{}) error
Error creates a new callable error with the specified status and message.
Types ¶
type Call ¶
type Call struct { // UID is the client's Firebase Auth user ID. See WithAuth to set up // Firebase Auth token validation. UID string // IID is the Firebase Instance ID token (the FCM registration token). // Can be used to target push notifications. IID string }
Call carries contextual information on the current function call.
type Callable ¶
type Callable struct {
// contains filtered or unexported fields
}
Callable encapsulates a Firebase 'onCall' request with its handler method.
func New ¶
New creates a new Callable for the given Request object. When serving a HTTP request, the Callable will use the Request object as a target for JSON decoder. After the request body is unmarshalled, the Handle method is called to process the call. Returned value is encoded as JSON and sent back to the client.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option configures a Callable.
func WithAuth ¶
WithAuth specifies the Firebase Auth client that will be used to validate ID tokens. The `required` flag controls whether a valid ID token is required or not.
func WithLogger ¶
WithLogger adds a logger that will be used to log errors.
type Request ¶
type Request interface { // Handle is called after the JSON request body is decoded into this // Request. Returned values are encoded to JSON response. // // Use the Error function to create errors with a specified status code. // Generic errors are encoded as an 'INTERNAL' error response. Handle(context.Context, Call) (interface{}, error) }
Request represents the call request data and provides a method to handle it.
type StatusCode ¶
type StatusCode int
StatusCode distinguishes between different error causes. See https://cloud.google.com/apis/design/errors#http_mapping.
const ( InvalidArgument StatusCode = iota FailedPrecondition OutOfRange Unauthenticated PermissionDenied NotFound Aborted AlreadyExists ResourceExhausted Cancelled DataLoss Unknown Internal NotImplemented DeadlineExceeded )