Simple RESTful API used to create and retrieve portfolio data for my personal website, built using Go and MongoDB.
# Install mux router
go get -u github.com/gorilla/mux
# Install MongoDB Driver
go get go.mongodb.org/mongo-driver
# Install govalidator
go get github.com/thedevsaddam/govalidator
# Replace values in config/config.go with your own DB Uri and Port.
func GetConfig() *Config {
uri, exists := os.LookupEnv("DB_URI")
if exists {
return &Config{
DbURI: uri,
Port: ":8080",
}
}
return &Config{}
}
# Run
go run main.go
GET /api/projects
POST /api/projects
# Request body
{
"Title":"My Website API", # string
"Description":"Simple RESTful API", # string
"Img":"assets/img/go.png", # string
"Link":"https://github.com/liamreardon/my-website-api", # string
"Tools":"Go, MongoDB", # string
"DateAdded":"2020-04-06" # string
}
PUT /api/projects/:title
# URL
localhost:8080/api/projects/Project-Title
# Request body of document to update
{
"Title":"My Website API", # string
"Description":"Simple RESTful API", # string
"Img":"assets/img/go.png", # string
"Link":"https://github.com/liamreardon/my-website-api", # string
"Tools":"Go, MongoDB", # string
"DateAdded":"2020-04-06" # string
}
DELETE /api/projects/:title
GET /api/courses
POST /api/courses
# Request body
{
"Title":"COMP 1000" # string
}
PUT /api/courses/:title
# URL
localhost:8080/api/projects/Course-Title
# Request body of document to update
{
"Title":"COMP 1000" # string
}
DELETE /api/courses/:title
- Write unit tests for all packages