micro

package module
v1.0.0-beta3 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: MIT Imports: 9 Imported by: 0

README

micro

This is a microservice library for Go and AWS Lambda.

Description

This library is a collection of utilities for building microservices in Go and AWS Lambda. It is designed to be used with the AWS Lambda Go SDK.

It is not a framework, but rather a collection of utilities that can be used to build a framework.

License

See License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Send

func Send(ctx context.Context, input *SendInput) error

Types

type Handler

type Handler func(ctx context.Context, request Request) (Response, error)

type M

type M = map[string]interface{}

type Option

type Option func(*Service)

type Request

type Request struct {
	Body                  string              `json:"body"`
	Headers               map[string]string   `json:"headers"`
	HTTPMethod            string              `json:"httpMethod"`
	Path                  string              `json:"path"`
	Resource              string              `json:"resource"`
	MultiValueHeaders     map[string][]string `json:"multiValueHeaders"`
	QueryParams           map[string]string   `json:"queryStringParameters"`
	MultiValueQueryParams map[string][]string `json:"multiValueQueryStringParameters"`
	RequestContext        RequestContext      `json:"requestContext"`
	PathParams            map[string]string   `json:"pathParameters"`
}

func (Request) Bind

func (r Request) Bind(v interface{}) error

func (Request) GetHeader

func (r Request) GetHeader(key string) (string, error)

func (Request) GetRequestID

func (r Request) GetRequestID() string

func (Request) PathParam

func (r Request) PathParam(key string) (string, error)

func (Request) Query

func (r Request) Query(key string) (string, error)

type RequestContext

type RequestContext struct {
	RequestID string `json:"requestId"`
	Stage     string `json:"stage"`
}

type Response

type Response struct {
	StatusCode int         `json:"statusCode"`
	Body       interface{} `json:"body"`
}

func JSON

func JSON(statusCode int, body interface{}) Response

func SendAndWait

func SendAndWait(ctx context.Context, input *SendInput) (*Response, error)

type SendInput

type SendInput struct {
	FunctionName string
	Path         string
	Method       string
	Payload      interface{}
	RequestID    string // optional
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(name string, opts ...Option) *Service

func (*Service) DELETE

func (s *Service) DELETE(path string, handler Handler)

func (*Service) GET

func (s *Service) GET(path string, handler Handler)

func (*Service) Handler

func (s *Service) Handler(ctx context.Context, request Request) (Response, error)

func (*Service) PATCH

func (s *Service) PATCH(path string, handler Handler)

func (*Service) POST

func (s *Service) POST(path string, handler Handler)

func (*Service) PUT

func (s *Service) PUT(path string, handler Handler)

func (*Service) Start

func (s *Service) Start()

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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