Skip to content

jeroendee/go-demo-web-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
}

About

Demo web-api written in Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages