Skip to content

Basic REST API built in Golang for the sake trying Golang. Includes GET, POST requests handling along with Unit Test using Golang. Uses MongoDB for storing records.

Notifications You must be signed in to change notification settings

prateekbose/go-backend-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go example API

  • Create an User
  • Get a user using id
  • Create a Post
  • Get a post using id
  • List all posts of a user

Create an User

The user can create account using the API by going to '/users'. Supports only POST requests.

Get a user using id

Returns user details using the API by going to ‘/users/{id}’. Supports only GET requests. Throws error if the user does not exist.

Create a Post

The user can create posts using the API by going to '/posts'. Supports only POST requests. Throws an error if the user with given ID does not exists.

Get a post using id

Returns post content using the API by going to ‘/posts/{id}’. Supports only GET requests. Throws an error if the post with given ID does not exists.

List all posts of a user

Returns array containing all posts of a user using the API by going to ‘/posts/users/{id}’. Supports only GET requests. Throws an error if the user with given ID does not exists.

Unit Tests

Added Unit Tests

  • AddUserSuccess
  • AddPostSuccess
  • AddPostUnauthorized
  • GetUser
  • GetPost
  • GetUserPosts

About

Basic REST API built in Golang for the sake trying Golang. Includes GET, POST requests handling along with Unit Test using Golang. Uses MongoDB for storing records.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages