Categorygithub.com/apex/go-apex
modulepackage
1.0.0
Repository: https://github.com/apex/go-apex.git
Documentation: pkg.go.dev

# README

Apex Golang

Golang runtime support for Apex/Lambda – providing handlers for Lambda sources, and runtime requirements such as implementing the Node.js shim stdio interface.

Features

Currently supports:

  • Node.js shim
  • Environment variable population
  • Arbitrary JSON
  • CloudWatch Logs
  • Cognito
  • Kinesis
  • Dynamo
  • S3
  • SNS
  • SES

Example

package main

import (
  "encoding/json"
  "strings"

  "github.com/apex/go-apex"
)

type message struct {
  Value string `json:"value"`
}

func main() {
  apex.HandleFunc(func(event json.RawMessage, ctx *apex.Context) (interface{}, error) {
    var m message

    if err := json.Unmarshal(event, &m); err != nil {
      return nil, err
    }

    m.Value = strings.ToUpper(m.Value)

    return m, nil
  })
}

Run the program:

echo '{"event":{"value":"Hello World!"}}' | go run main.go
{"value":{"value":"HELLO WORLD!"}}

Notes

Due to the Node.js shim required to run Go in Lambda, you must use stderr for logging – stdout is reserved for the shim.

Badges

Build Status GoDoc


tjholowaychuk.com  ·  GitHub @tj  ·  Twitter @tjholowaychuk

# Packages

No description provided by the author
Package cloudformation provides structs for working with AWS CloudFormation custom resources.
No description provided by the author
Package cognito provides structs for working with AWS Cognito records.
Package dynamo provides structs for working with AWS Dynamo records.
Package kinesis provides structs for working with AWS Kinesis records.
Package logs provides structs for working with AWS CloudWatch Logs records.
No description provided by the author
Package s3 provides structs for working with AWS S3 records.
Package ses provides structs for working with AWS SES records.
No description provided by the author
Package sns provides structs for working with AWS SNS records.

# Functions

Handle Lambda events with the given handler.
HandleFunc handles Lambda events with the given handler function.

# Structs

Context represents the context data provided by a Lambda invocation.
Identity as defined in: http://docs.aws.amazon.com/mobile/sdkforandroid/developerguide/lambda.html#identity-context.

# Interfaces

Handler handles Lambda events.

# Type aliases

HandlerFunc implements Handler.