util

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2018 License: MIT Imports: 13 Imported by: 1

README

lambda-util - A collection of utility methods for my serverless apps

A collection of utility methods for my serverless apps

Layout

.                                   
├── http.go         <-- Utils to interact with HTTP requests
├── os.go           <-- Utils to interact with the Operating System
├── s3.go           <-- Utils to interact with Amazon S3
├── ses.go          <-- Utils to interact with Amazon Simple Email Service
├── ssm.go          <-- Utils to interact with Amazon SSM
├── .gitignore      <-- Ignoring the things you do not want in git
├── LICENSE         <-- The license file
└── README.md       <-- This file

Documentation

Overview

Package util implements utility methods

Package util implements utility methods

Package util implements utility methods

Package util implements utility methods

Package util implements utility methods

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(awsSession *session.Session, filename string, bucket string) error

CopyFile creates a copy of an existing file with a new name

func DownloadFile

func DownloadFile(awsSession *session.Session, folder string, filename string, bucket string) error

DownloadFile downloads a file from Amazon S3 and stores it in the specified location.

func GetCurrentDirectory added in v1.1.0

func GetCurrentDirectory() (string, error)

GetCurrentDirectory gets the directory in which the app was started and returns either the full directory or an error

func GetEnvKey

func GetEnvKey(key string, fallback string) string

GetEnvKey tries to get the specified key from the OS environment and returns either the value or the fallback that was provided

func GetSSMParameter

func GetSSMParameter(awsSession *session.Session, name string, decrypt bool) (string, error)

GetSSMParameter gets a parameter from the AWS Simple Systems Manager service.

func SendEmail

func SendEmail(awsSession *session.Session, toAddress string, bodyContent string, fromAddress string, subject string) error

SendEmail sends an email using Simple Email Service.

func UploadFile

func UploadFile(awsSession *session.Session, folder string, filename string, bucket string) error

UploadFile uploads a file to Amazon S3

Types

type HTTPResponse

type HTTPResponse struct {
	Body       map[string]interface{}
	StatusCode int
	Headers    http.Header
}

HTTPResponse is the response type for the HTTP requests

func HTTPGet

func HTTPGet(URL string, encoding string, header http.Header) (HTTPResponse, error)

HTTPGet executes a GET request to a URL and returns the response body as a JSON object

func HTTPPatch added in v1.1.0

func HTTPPatch(URL string, encoding string, postData string, header http.Header) (HTTPResponse, error)

HTTPPatch executes a PATCH request to a URL and returns the response body as a JSON object

func HTTPPost

func HTTPPost(URL string, encoding string, postData string, header http.Header) (HTTPResponse, error)

HTTPPost executes a POST request to a URL and returns the response body as a JSON object

Jump to

Keyboard shortcuts

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