Senthilsweb
Search
Blog

Open sourced new Go API Server which can be deployed 100% free in Netlify

I started notifier golang api project as multipurpose notification library to send mail, text, slack, push, telegram etc. but it is expanding as enterprise grade frictionless api server with low memory footprint. It is designed in such a manner that, it can be hosted as aws lambda function or any cloud provider or on-prem in bare metal. As of this writing, the size of the golang binary is just ~20 MB.

This is very well suited to host it in Netlify 100% free and yes, Netlify won’t ask for your credit card details for registration.

Design Goals

Pre-requisites

  • Should have Go installed in your local development environment
  • Optional netlify account to deploy this golang api as serverless functions
  • Optional netlify CLI
  • Optional if you want to send HTML formatted email using mailgun template. I used Maizzle to build HTML emails with Tailwind CSS https://maizzle.com/
  • mailgun account as the notify (sendmail) api is built using mailgun
  • VSCode Editor or Gitpod online VSCode editor 50 hours per month free plan

Local Development

Clone repository.

git clone https://github.com/senthilsweb/notifier.git

Local build (Mac OS)

go build

Local Run

./notifier -p "3000"

REST Endpoints

The following APIs implemented and readily available to use in your projects. For quick testing, you can try from the hosted version of mine in netlify. Please change the end-point relative url to yours.

https://zybes.netlify.app/api

Request Endpoints Functionality
POST https://zybes.netlify.app/api/notify/mailgun Send email
GET https://zybes.netlify.app/api/ping Health check

Payload for https://zybes.netlify.app/api/notify/mailgun

{
    "message": {
        "subject": "This is subject",
        "body": "This is body",
        "template": "welcome_email",
        "recipient": "name <your email@gmail.com>",
        "payload": {"name":"John Smith"}
    },
    "MAILGUN_DOMAIN": "your domain",
    "MAILGUN_KEY": "your key",
    "EMAIL_SENDER": "Mailgun Sandbox <your sender>"
}

Netlify Deployment

Refer the following documentaion and blog post to host the server (and optional Single Page Application) at Netlify

Key Frameworks and Libraries used

  • github.com/apex/gateway
  • github.com/gin-gonic/gin
  • github.com/mailgun/mailgun-go/v4
  • github.com/sirupsen/logrus
  • github.com/spf13/viper
  • github.com/tidwall/gjson