📖 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
  • Scout APM - Less time debugging, more time building
  • SonarLint - Deliver Cleaner and Safer Code - Right in Your IDE of Choice!
  • 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

  • Scout APM

    Less time debugging, more time building. Scout APM allows you to find and fix performance issues with no hassle. Now with error monitoring and external services monitoring, Scout is a developer's best friend when it comes to application development.

  • 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

    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.

  • SonarLint

    Deliver Cleaner and Safer Code - Right in Your IDE of Choice!. SonarLint is a free and open source IDE extension that identifies and catches bugs and vulnerabilities as you code, directly in the IDE. Install from your favorite IDE marketplace today.

  • 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

    🧬 JWT middleware for Fiber (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