Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Deploying fiber on Netlify

Netlify Status

Based on the fiber-lambda API written by Fenny. Since the code hasn't been merged yet, I borrowed it into adapter/adapter.go

The app uses static pages under public directory. These are compiled using sveltejs and the complete template can be found here.

# netlify.toml

[build]
  command = "./build.sh"
  functions = "functions"
  publish = "public"

[build.environment]
  GO_IMPORT_PATH = "github.com/amalshaji/fiber-netlify"
  GO111MODULE = "on"

[[redirects]]
  from = "/api/*"
  to = "/.netlify/functions/gateway/:splat"
  status = 200

Deploying net/http to Netlify explains what these functions are doing. You can read it here.

TL;DR

  • build command builds the whole code to binary cmd/gateway/gateway
  • we're building something called netlify functions (Please read)
  • everything under public folder will be published(entrypoint: index.html)
  • Netlify maps endpoints to /.netlify/functions/gateway, which is weird when you do requests, so we redirect it to /api/*
  • status = 200 for server side redirects

Important

Netlify functions allows you to have up to 125,000 requests a month. This means you can have 2.89 requests per minute. Make sure you use Cache in you request handlers.