gofiber-template-server

command module
v1.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2022 License: MIT Imports: 8 Imported by: 0

README

Gofiber Template Server

Maintenance Ask Me Anything !

Description

A template gofiber server with basic functionality and structure ready to fork and spin up a server.

Prerequisites

For running and developing in this repository you will have to install some tools

  • npm or yarn as it uses some tools like husky and semantic-release.
  • After install npm or yarn you can install dependencies with executing npm i or yarn in the root
  • For local development you can use nodemon for hot reloading. You can install it with npm i nodemon -g or yarn global add nodemon. make dev starts the server in hot reload.
  • You will need go, docker, golangci-lint installed locally.

Contents

  • This repository is ready for start developing. You can find ./app/controllers folder where route controllers are added and in ./pkg/routes/app_routes.go you can register your new routes.

  • Inside the repository you can find also *_test.go files containing some basic unit tests.

  • In the root folder there is also a Dockerfile for building an image of your application.

  • Also a Makefile is provided with some basic commands. You can type make help for an overview of the commands.

  • .env.example you can create an .env file with your own values cp .env.example .env. The .env value is only loaded when in development.

  • Swagger Documentation. If you run server and visit localhost:8080/swagger/index.html you can see some basic documentation for the routes.

Usage

For starting server in hot reload mode and developing you can do it with make dev.

Docker

Build Image:

docker build . -t gofiber-server

Run Container:

docker run --rm -p <host-port>:<server-port> --name gofiber-server gofiber-server
Profiling

For profiling you will need to have installed graphviz

In development profiling is enabled. You can visit localhost:8080/debug/pprof/ and run from there the profiling. While the profiling runs you can put some stress to your server (e.g. autocannon). After the profiling finishes a profile file will be downloaded and with the command go tool pprof -http=:8081 profile you can visit a UI with the graphs.

Useful commands
  • Run tests make test
  • Run linter make lint
  • Build application make build
  • Update swagger docs make update-swagger

Licence

MIT License

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
app
Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT This file was generated by swaggo/swag
Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT This file was generated by swaggo/swag

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL