📖 Build a RESTful API on Go: Fiber, PostgreSQL, JWT and Swagger docs in isolated Docker containers

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • Fiber

    ⚡️ Express inspired web framework written in Go

  • I think, this functionality is enough to help you understand, how easy it is to work with Fiber web framework to create a REST API in Go.

  • tutorial-go-fiber-rest-api

    📖 Build a RESTful API on Go: Fiber, PostgreSQL, JWT and Swagger docs in isolated Docker containers.

  • View on GitHub

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • migrate

    Database migrations. CLI and Golang library.

  • 👍 I recommend to use golang-migrate/migrate tool for easily up & down your database migrations in one console command.

  • ctop

    Top-like interface for container metrics

  • Check, if the container is running. For example, by ctop console utility:

  • swag

    Automatically generate RESTful API documentation with Swagger 2.0 for Go.

  • swaggo/swag package for easily generate Swagger config in Go;

  • fiber-swagger

    Discontinued fiber middleware to automatically generate RESTful API documentation with Swagger 2.0.

  • arsmn/fiber-swagger official Fiber's middleware;

  • uuid

    Go package for UUIDs based on RFC 4122 and DCE 1.1: Authentication and Security Services. (by google)

  • 👍 I recommend to use the google/uuid package to create unique IDs, because this is a more versatile way to protect your application against common number brute force attacks. Especially if your REST API will have public methods without authorization and request limit.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • validator

    :100:Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving

  • 👌 I use go-playground/validator v10 for release this feature.

  • jwt

    Discontinued ⚠️ Deprecated repository, available within Fiber Contrib. (by gofiber)

  • // ./pkg/middleware/jwt_middleware.go package middleware import ( "os" "github.com/gofiber/fiber/v2" jwtMiddleware "github.com/gofiber/jwt/v2" ) // JWTProtected func for specify routes group with JWT authentication. // See: https://github.com/gofiber/jwt func JWTProtected() func(*fiber.Ctx) error { // Create config for JWT authentication middleware. config := jwtMiddleware.Config{ SigningKey: []byte(os.Getenv("JWT_SECRET_KEY")), ContextKey: "jwt", // used in private routes ErrorHandler: jwtError, } return jwtMiddleware.New(config) } func jwtError(c *fiber.Ctx, err error) error { // Return status 401 and failed authentication error. if err.Error() == "Missing or malformed JWT" { return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{ "error": true, "msg": err.Error(), }) } // Return status 401 and failed authentication error. return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{ "error": true, "msg": err.Error(), }) }

  • Testify

    A toolkit with common assertions and mocks that plays nicely with the standard library

  • ☝️ As always, I will use Fiber's built-in Test() method and an awesome package stretchr/testify for testing Golang apps.

  • swagger-ui

    Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.

  • As you can guess from the title, we're not going to worry too much about documenting our API methods. Simply because there is a great tool like Swagger that will do all the work for us!

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts