mu

package module
v0.0.0-...-c90a592 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2019 License: Apache-2.0 Imports: 12 Imported by: 2

README

mu

mu is an AWS Lambda helper that allows for re-purposing HTTP API projects quickly into lambdas.

Example

import (
	"net/http"

	"github.com/ModelRocket/mu"
	"github.com/gorilla/mux"
)

func productHandler(w http.ResponseWriter, r *http.Request) {
	w.WriteHeader(http.StatusOK)
}

func main() {
	r := mux.NewRouter()

	r.HandleFunc("/products/{key}", productHandler)

	mu.Start(r)
}

Documentation

Index

Constants

View Source
const APIGatewayProxyRequestKey key = 0

APIGatewayProxyRequestKey is the context key

Variables

This section is empty.

Functions

func GetProxyEvent

func GetProxyEvent(r *http.Request) *events.APIGatewayProxyRequest

GetProxyEvent returns the proxy event for the request

func NewRequest

func NewRequest(event events.APIGatewayProxyRequest) (request *http.Request, err error)

NewRequest returns a new *http.Request for the APIGatewayProxyRequest event

func Start

func Start(handler http.Handler) error

Start is the lambda entry point

Types

type Response

type Response struct {
	events.APIGatewayProxyResponse
	// contains filtered or unexported fields
}

Response defines a struct that conforms to the API Gateway Labmbda Response

func NewResponse

func NewResponse() *Response

NewResponse returns a new response object

func (*Response) Header

func (r *Response) Header() http.Header

Header implements the http.ResponseWriter.Header() method

func (*Response) Write

func (r *Response) Write(body []byte) (int, error)

Write implements the http.ResponseWriter.Write() method

func (*Response) WriteHeader

func (r *Response) WriteHeader(statusCode int)

WriteHeader implements the http.ResponseWriter.WriteHeader() method

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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