This is a super fast REST-API Server for simple blogs written in golang.
sfhb is powered by a realy simple data structure
type Article struct {
Id uuid.UUID `json:"id"`
Title string `json:"title"`
Type string `json:"type"`
Content string `json:"content"`
Created time.Time `json:"created"`
}
this translates to simple json
{
id: "uuid",
title: "title"
type: "whatever"
content: "yay"
created: "ISO 8601 date string"
}
sfhb will store its data in a single json file: data.json
- GET
/articles Returns all articles in chronological order
/article/{id} Returns a single article by id
- POST
/article
Takes a JSON Object with following keys: title
, type
, content
as Body. id
and created
fields will be generated by sfhb.
Returns the created Object.
- DELETE
/article/{id} Deletes Articles by ID
There are two .env Variables you can set
PORT (default: 8080) TOKEN (default: none)
The token is used for authentication of POST and DELETE endpoints
Docker image is available on Docker Hub
docker run -p 8080:8080 -e TOKEN=mysecrettoken chwzr/sfhb