server/

directory
v0.0.0-...-77bbea8 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2020 License: MIT

README

Server

API

The API is specified with OpenAPI 2.0 in swagger.yml. JetBrains IDEs have excellent support for OpenAPI specifications. For VS Code users, you can consider the Swagger Viewer and OpenAPI (Swagger) Editor extensions.

On the server side, we use go-swagger to automatically generate some boilerplate for the server. Every time swagger.yml changes, one should run make generate to ensure the boilerplate is up to date.

You can view a generated API documentation by running make start and visiting http://localhost:9000/docs.

Installing Go

Go ≥1.15 is required.

macOS: (needs Homebrew)

$ brew install go
$ go version
go version go1.15.3 darwin/amd64

Arch Linux and derivatives:

$ sudo pacman -S go
$ go version
go version go1.15.3 linux/amd64

Ubuntu: (documentation)

$ sudo add-apt-repository ppa:longsleep/golang-backports
$ sudo apt update
$ sudo apt install golang-go
$ go version
go version go1.15.3 linux/amd64

Others (including Windows): follow official guide

$ go version
go version go1.15.3 windows/amd64

Common operations

To start the server:

make start

To reformat code:

make format

To regenerate boilerplate code:

make generate

Code organization

Things we can edit:

  • impl contains endpoint implementations.
  • restapi/configure_down_to_meet.go contains server configurations. Every time we add a new endpoint, we need to add a line to configureAPI that sets the handler appropriately.

Things that are automatically generated, and should not be edited:

  • cmd/down-to-meet-server is the generated source code for the server binary.
  • models contains the generated data structures.
  • restapi (except configure_down_to_meet.go) contains generated server code.

Directories

Path Synopsis
cmd
Package db implements DownToMeet server's connection to the PostgreSQL database.
Package db implements DownToMeet server's connection to the PostgreSQL database.
Package impl contains the business logic of the DownToMeet server.
Package impl contains the business logic of the DownToMeet server.
nonce
Package nonce implements a simple ASCII nonce generator, as well as some randomization utilities.
Package nonce implements a simple ASCII nonce generator, as well as some randomization utilities.
responders
Package responders contains implementations of middleware.Responder that can be useful for any endpoint.
Package responders contains implementations of middleware.Responder that can be useful for any endpoint.
Package restapi Internal DownToMeet API Schemes: http Host: localhost BasePath: / Version: 1.0.0 Consumes: - application/json Produces: - text/html - application/json swagger:meta
Package restapi Internal DownToMeet API Schemes: http Host: localhost BasePath: / Version: 1.0.0 Consumes: - application/json Produces: - text/html - application/json swagger:meta

Jump to

Keyboard shortcuts

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