Git Product home page Git Product logo

aws-sam-golang-example's Introduction

AWS SAM Golang Example

Build Status Go Report Card

An example API written in Golang using the Amazon Serverless Application Model (AWS SAM).

Overview

Go is arguably one of the easiest languages in which to write a RESTful API. With the addition of Go support for AWS Lambda coupled with the maturity of tooling around the AWS Serverless Application Model, deploying the API to serverless infrastructure is becoming much more straightforward, too. Thanks to the APEX Gateway, you can even write APIs in a familiar manner without changing how the code is structured.

The purpose of this project is to give a slightly more complicated example than the "hello world" ones provided by Amazon to show how Go's standard net/http package can play nicely in a serverless world with AWS API Gateway and Lambda. It also shows how you can use Go and Amazon's tooling to develop and test your API locally within in this model.

Prerequisites

Installation

With a correctly configured Go toolchain:

go get -u github.com/cpliakas/aws-sam-golang-example

Usage

Run the API Locally

โš ๏ธ Make sure to install all the Prerequisites. On Mac OSX and Windows, ensure that the Docker VM is running.

Build the binary, and run the API locally:

GOOS=linux go build -o main
sam local start-api

You can now consume the API using your tool of choice. HTTPie is pretty awesome.

http localhost:3000/hello
HTTP/1.1 200 OK
Content-Length: 28
Content-Type: application/json; charset=utf8
Date: Sat, 03 Feb 2018 20:12:07 GMT

{
    "message": "Hello, world!"
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.