Skip to content
프로젝트

dhax/go-base has 1,691 GitHub stars and 241 forks. GitHot measured 0 stars in 24 hours, -4 in 7 days, and -3 in 15 days. Last checked 2026-11-24 02:21 UTC. Last push 2026-11-18.

이 수치를 측정하는 방법

What you can do

  • Configuration using viper
  • CLI features using cobra
  • PostgreSQL support including migrations using bun
  • Structured logging with Logrus

측정된 스타 증가

in 24h
0
in 7 days
-4
in 15 days
-3
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

소개

PostgreSQL을 기반으로 JWT 인증을 지원하는 Go RESTful API 보일러플레이트

데이터

README.md

Original

Go Restful API Boilerplate

GoDoc Badge

Easily extendible RESTful API boilerplate aiming to follow idiomatic go and best practice.

The goal of this boiler is to have a solid and structured foundation to build upon on.

Any feedback and pull requests are welcome and highly appreciated. Feel free to open issues just for comments and discussions.

Features

The following feature set is a minimal selection of typical Web API requirements:

Start Application

  • Clone and change into this repository

Local

  • Create a postgres database
  • Copy .env.example to .env and adjust, especially set a default AUTH_JWT_SECRET
  • Run the application to see available commands: go run main.go
  • Run all migrations from database/migrate folder: go run main.go migrate
  • Run the application with command serve: go run main.go serve

Using Docker Compose

  • Change the default AUTH_JWT_SECRET environment variable in docker-compose.yml
  • First start the database only: docker compose up -d postgres
  • Once initialize the database by running all migrations in database/migrate folder: docker compose run server ./main migrate
  • Start the api server: docker compose up

API Routes

Authentication

During development if no valid email smtp settings are provided by configuration outgoing emails containing the login token will be printed to terminal's stdout. If EMAIL_SMTP_HOST is set but cannot be reached the application will exit immediately at start.

For passwordless login following routes are available:

Path Method Required JSON Header Description
/auth/login POST email the email you want to login with (see below)
/auth/token POST token the token you received via email (or printed to stdout if smtp not set)
/auth/refresh POST Authorization: "Bearer refresh_token" refresh JWTs
/auth/logout POST Authorizaiton: "Bearer refresh_token" logout from this device

Example API

The example api follows the patterns from the chi rest example. Besides /auth routes the API provides two main routes for /api and /admin requests, the latter requires to be logged in as administrator by providing the respective JWT in Authorization Header.

Check routes.md for a generated overview of the provided API routes.

Testing

Package auth/pwdless contains example api tests using a mocked database. Run them with: go test -v ./...

Client API Access and CORS

The server is configured to serve a Progressive Web App (PWA) client from ./public folder (this repo only serves an example index.html, see below for a demo PWA client to put here). In this case enabling CORS is not required, because the client is served from the same host as the api.

If you want to access the api from a client that is served from a different host, including e.g. a development live reloading server with below demo client, you must enable CORS on the server first by setting environment variable ENABLE_CORS=true on the server to allow api connections from clients served by other hosts.

Demo client application

A (now archived) demo Vue.js PWA client's source code can be found here. You can build and put it into the api's ./public folder, or use the live development server (requires ENABLE_CORS environment variable set to true).

관련 프로젝트 살펴보기

불러오는 중…