Skip to content

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

License

Notifications You must be signed in to change notification settings

liamreardon/my-website-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages