https://github.com/sjoshi6/go-rest-api-boilerplate
Boiler plate for developing a go lang based REST API with commonly used open source libraries
https://github.com/sjoshi6/go-rest-api-boilerplate
api bolierplate go golang gorilla-mux logrus negroni rest-api restful-api
Last synced: 4 months ago
JSON representation
Boiler plate for developing a go lang based REST API with commonly used open source libraries
- Host: GitHub
- URL: https://github.com/sjoshi6/go-rest-api-boilerplate
- Owner: sjoshi6
- License: mit
- Created: 2017-04-06T02:54:20.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-07-04T22:35:06.000Z (almost 8 years ago)
- Last Synced: 2024-06-20T07:58:32.276Z (almost 2 years ago)
- Topics: api, bolierplate, go, golang, gorilla-mux, logrus, negroni, rest-api, restful-api
- Language: Go
- Size: 12.7 KB
- Stars: 7
- Watchers: 3
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-rest-api-boilerplate
Boiler plate for developing a go lang based REST API with commonly used open source libraries
### Boilerplate Run instructions:
###### Note: Make sure your go environment is correctly setup for development.
Run the below commands in order on commandline
```python
# Install the glide package manager
curl https://glide.sh/get | sh
# Clone the boilerplate project
git clone https://github.com/sjoshi6/go-rest-api-boilerplate.git
cd go-rest-api-boilerplate
# (Optional) Update the dependencies
glide update
# Installs all dependencies in project vendor folder.
glide install
# builds the application and creates a binary go-rest-api-boilerplate
go build
# Run the API server
GO_ENV_PORT=8000 ./go-rest-api-boilerplate
```
OR
Run the following docker commands
```python
cd go-rest-api-boilerplate
# Build the docker image
docker build -t go-boilerplate .
# Run the API in a container. Replace with 8000
docker run -p :8000 go-boilerplate
```
### Check the API output
```
curl http://localhost:8000/v1/users/1
```
Expected Output:
```
{"ID":0,"CreatedAt":"0001-01-01T00:00:00Z","UpdatedAt":"0001-01-01T00:00:00Z","DeletedAt":null,"age":35,"first_name":"bruce","last_name":"wayne"}
```
===================================================================================
```
curl http://localhost:8000/v1/users
```
Expected Output:
```
[{"ID":0,"CreatedAt":"0001-01-01T00:00:00Z","UpdatedAt":"0001-01-01T00:00:00Z","DeletedAt":null,"age":35,"first_name":"bruce","last_name":"wayne"},{"ID":0,"CreatedAt":"0001-01-01T00:00:00Z","UpdatedAt":"0001-01-01T00:00:00Z","DeletedAt":null,"age":35,"first_name":"batman","last_name":""}]
```