项目作者: scharissis

项目描述 :
An opinionated skeleton implementation of a Go http web server.
高级语言: Go
项目地址: git://github.com/scharissis/go-server-skeleton.git
创建时间: 2020-05-26T02:56:42Z
项目社区:https://github.com/scharissis/go-server-skeleton

开源协议:MIT License

下载


Skeleton Go Web Server

Build (Go)/badge.svg?branch=master>)
Go Report Card
go.dev reference

A very simple template for a golang web service.

It is opinionated and intended to act as an example of best practices.

Building & Running

  • Build

    ./build.sh (recommended), OR

    go build ./...

  • Run

    go run main/skeleton.go

What’s here?

  1. A web server, which:

    • Exposes one method (/api/answer), which allows GET and POST and responds with JSON

      1. GET /api/answer // 'Hello!'
      2. POST /api/answer 'Stefano' // 'Hello, Stefano!'
    • Has middleware to limit the type of HTTP request a method will allow

    • Shuts down gracefully
  2. An example 3rd party service client library (skeleton/numbers)

  3. Tests

Design choices at a glance

  • Server shuts down gracefully
  • Routes go in their own file
  • API unit tests use testify: github.com/stretchr/testify/assert

Contributing

Contributions are very welcome!

Submit a pull request with:

  1. New functionality or edits.
  2. Tests covering the above.
  3. Reasoning as to why it should be included.