lowcode

package module
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

README

aws-lowcode-lambda-go

Creating a config file

# config.yaml
TemplateFormatVersion: 2024-01-31
Description: lowcode-lambda configuration

Resources:
  Request:
    AllowedMethods:
    - GET
    - POST
    - PUT

  Database:
    TableName: users
    Keys:
      email:
        Operator: "="
      order:
        Operator: "="
    Filter: "#age > :age"
    FilterValues:
      age: "5"
    ProjectionCols:
    - email
    - username
    - age
  
  Response:
    DataStruct: '[{"username": "", "age": ""}]'

Building a lowcode lambda function

// main.go
package main

import (
  "os"
  "fmt"

  "github.com/raywall/aws-lowcode-lambda-go/config"
	"github.com/raywall/aws-lowcode-lambda-go/server/clients/dynamodb"
	"github.com/raywall/aws-lowcode-lambda-go/server/handlers"
)

func init() {
  conf := &config.Global

	data, err := os.ReadFile(os.Getenv("CONFIG_SAMPLE"))
	if err != nil {
		log.Fatalf("failed reading lowcode role file: %v", err)
	}

	err = conf.Load(data)
	if err != nil {
		log.Fatalf("failed loading settings: %v", err)
	}

  // create a handler for integration between an api gateway and a dynamodb table
	handlers.Client, err = dynamodb.NewDynamoDBClient(conf)
	if err != nil {
		log.Fatalf("failed starting a dynamodb client: %v", err)
	}
}

func main() {
    // make the handler available for remote procedure call by aws lambda
    lambda.Start(handlers.HandleLambdaEvent)
}

Testing your function locally with SAM


# building your project
sam build

# running your function
sam local start-api

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Function added in v0.1.15

type Function config.Settings

func (*Function) HandleRequest added in v0.1.15

func (function *Function) HandleRequest(ctx context.Context, evt interface{}) (interface{}, error)

func (*Function) NewWithConfig added in v0.1.15

func (function *Function) NewWithConfig(filePath string) error

type Lowcode added in v0.1.15

type Lowcode interface {
	NewWithConfig(filePath string) error
	HandleRequest(ctx context.Context, evt interface{}) (interface{}, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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