Skip to content

Latest commit

 

History

History
57 lines (40 loc) · 1.75 KB

README.md

File metadata and controls

57 lines (40 loc) · 1.75 KB

Go demo web-api

Demo web-api written in Go

Effectively the rest example from the official chi project is used and adapted according to need.

Goal

Offer a simple API that can be run easily locally. This API can be treated as a "System Under Test" for api testing.

Architectural Decision(s)

Principle: don't rely on modules that by themselves rely on external depencendies.

http pipeline

The chosen http router is chi. This package provides convenience over having to write the http pipeline boilerplate using the Go std lib. This module is using only the Go std lib, and thus has no external dependencies.

fixture data

gofakeit is used to seed fixture struct data. This module is using only the Go std lib, and thus has no external dependencies.

Slices functions

Since the introduction of generics in Go 1.18 an experimental x/exp/slices package that offers convenience functions when using slices. This package has been accepted to be included in the official Go std lib

Usage

  1. Build the binary in /cmd/server
  2. Run the server binary in your terminal of choice => this will display: "Server starting on localhost:3000"

Endpoints to investigate:

GET:

  • /
  • /ping
  • /clients
  • /clients/{id}

POST:

  • /clients {payload}

PUT:

  • /clients/{id} {payload}

DELETE:

  • /clients/{id}

Payload example

{
    "id": string,
    "name": string,
    "surname": string,
    "birthdate": string,
    "email": string,
    "phone": string,
    "age": number
}