Skip to content

John-AG/go-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-rest-api

Currently this is a simple REST API built with Go, which I am using for personal development.

Setup

  1. Clone the repository:
git clone https://github.com/John-AG/go-rest-api.git
cd go-rest-api
  1. Install dependencies:
go mod tidy
  1. Run the application:
go run main.go
  1. The server will start on 'localhost:8080'. You can test it by navigating to 'http://localhost:8080/'. I'd recommend using Postman for this.

Prerequisites

Go 1.16+ PostgreSQL 'golang-migrate' for database migrations

Environment Variables

Create a '.env' file in the root of your project with the following content:

DATABASE_URL=postgres://username:password@hostname:port/database?sslmode=disable

Replace 'username', 'password', 'hostname', 'port' and 'database>' with your actual PostgreSQL credentials and database details.

Endpoints

'GET /': Returns a welcome message.

'GET /users' Returns a list of all users.

'GET /users/{id}' Returns a specific user based off the ID provided.

'POST /users' Create a new user.

'PUT /users/{id}' Update an existing user by ID.

'DELETE /users/{id}' Delete a user by ID.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages