Skip to content

tomkdickinson/serverless-hexagonal-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Severless Hexagonal Go Template

This is an opinionated Serverless Framework template that can be used to bootstrap a Go project to use a hexagonal architecture.

It's designed primarily for building microservices around lambdas.

Features

  • Implements a hexagonal layout, abstracting lambdas/storage from domain logic
  • Zerolog included for contextual JSON logging
  • Wire included to manage dependency injection

To Use

You can setup a new serverless project with this template with:

sls create --path {SERVICE_NAME} --template-url https://github.com/tomkdickinson/serverless-hexagonal-go/tree/main

Then run make gomodgen MODULE={MODULE_NAME} (or make gomodgen to auto generate module based on parent and folder name) to generate the go.mod and go.sum files.

This template also uses Wire for the examples, although you can easily be taken out if not needed.

Example Folder Structure

The example provided with this template is a simple Blog endpoint, where we want to find either a list of posts, or a specific post by its slug.

The cmd folder contains main applications for each lambda we declare in serverless.yml, including wiring of layers using Wire.

internal/lambda contains the actual lambda implementations for each http request.

internal/blog contains the domain logic for interacting with the blog.

internal/storage contains a simple memory implementation of the blogs repository, to load posts.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages