This server use only the standard library of go (http, fmt and json). Use routers, handlers and middlewares.
go run .
go build -o ./build/server && ./build/server
Server running in port :8000
http :8000
{"data": "Hello, World"}
http :8000/user Authorization:hola
TTP/1.1 200 OK
Content-Length: 138
Content-Type: application/json
Date: Sun, 23 Jan 2022 21:01:49 GMT
[
{
"email": "[email protected]",
"name": "John Doe"
},
{
"email": "[email protected]",
"name": "Bob"
},
{
"email": "[email protected]",
"name": "Alice"
}
]
http :8000/user Authorization:hola name=Andres email="[email protected]"
HTTP/1.1 201 Created
Content-Length: 47
Content-Type: application/json
Date: Sun, 23 Jan 2022 20:45:54 GMT
{
"email": "[email protected]",
"name": "Andres"
}
HTTP/1.1 401 Unauthorized
Content-Length: 0
Date: Sun, 23 Jan 2022 20:47:24 GMT