my-website-api

command module
v0.0.0-...-eba074c Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2020 License: GPL-3.0 Imports: 3 Imported by: 0

README

Simple Go RESTful API

Simple RESTful API used to create and retrieve portfolio data for my personal website, built using Go and MongoDB.

Quickstart

# 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

Endpoints

- Projects -
Get All Projects
GET /api/projects
Add a Project
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
}
Update a Project
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 a Project
DELETE /api/projects/:title
- Courses -
Get All Courses
GET /api/courses
Add a Course
POST /api/courses

# Request body
{
	"Title":"COMP 1000"	# string
}
Update a Course
PUT /api/courses/:title

# URL

localhost:8080/api/projects/Course-Title

# Request body of document to update
{
	"Title":"COMP 1000"	# string
}
Delete a Course
DELETE /api/courses/:title

TODO

  • Write unit tests for all packages

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
app

Jump to

Keyboard shortcuts

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