server

command
v0.0.0-...-f52eec7 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: MIT Imports: 11 Imported by: 0

README

Server setup

Start the API server

go run main.go

RESTful Routes

GET /persons - Get all people

Call the API with curl:

curl -X GET http://localhost:8080/persons

Returns a slice of JSON objects:

[
    {
        "id": "1234",
        "name": "Liam Hampton",
        "fact": "Likes F1",
        "location": "London"
    },
    {
        "id": "1234",
        "name": "Adelina Simion",
        "fact": "Likes coding",
        "location": "London"
    }
]
POST /persons - Create a person

Call the API with curl:

curl -X POST -H "Content-Type: application/json" -d '{
    "name": "Adelina Simion",
    "fact": "Likes coding",
    "location": "London"
}' localhost:8080/persons
TODO: POST /person/{id} - Delete a person

Call the API with curl:

curl -X POST -H "Content-Type: application/json" -d '{
    "id": "1234"
}' localhost:8080/person/{id}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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