serverless

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package serverless adapts a Nimbus application (any http.Handler, such as app.Router) to serverless invocation models — starting with AWS Lambda.

It has no AWS SDK dependency: it converts the Lambda proxy event JSON to a standard *http.Request, runs it through your handler, and converts the recorded response back to the Lambda proxy response shape. Your Lambda entry point wires it to the AWS runtime:

// cmd/lambda/main.go
package main

import (
    "github.com/aws/aws-lambda-go/lambda"
    "github.com/CodeSyncr/nimbus/serverless"
    "yourapp/bin"
)

func main() {
    app := bin.Boot()      // build the app (routes + middleware)
    _ = app.Boot()         // run providers/plugins (no HTTP listener)
    lambda.Start(serverless.Lambda(app.Router))
}

Supports both API Gateway / Lambda Function URL payload formats: v2.0 (HTTP API, Function URLs) and v1.0 (REST API, ALB).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler func(ctx context.Context, payload json.RawMessage) (Response, error)

Handler is the function signature aws-lambda-go's lambda.Start accepts.

func Lambda

func Lambda(h http.Handler) Handler

Lambda adapts an http.Handler (e.g. app.Router) into a Lambda handler.

type Response

type Response struct {
	StatusCode        int                 `json:"statusCode"`
	Headers           map[string]string   `json:"headers,omitempty"`
	MultiValueHeaders map[string][]string `json:"multiValueHeaders,omitempty"`
	Cookies           []string            `json:"cookies,omitempty"` // v2 only
	Body              string              `json:"body"`
	IsBase64Encoded   bool                `json:"isBase64Encoded"`
}

Response is the Lambda proxy response shape shared by API Gateway v1/v2, Function URLs, and ALB. The AWS runtime marshals this to JSON.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL