Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andhikayuana/simple-rest-go
Simple REST API using golang
https://github.com/andhikayuana/simple-rest-go
go go-api go-simple-rest golang
Last synced: about 5 hours ago
JSON representation
Simple REST API using golang
- Host: GitHub
- URL: https://github.com/andhikayuana/simple-rest-go
- Owner: andhikayuana
- Created: 2019-01-14T10:58:49.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-06T07:51:47.000Z (almost 6 years ago)
- Last Synced: 2024-11-17T08:49:10.634Z (2 months ago)
- Topics: go, go-api, go-simple-rest, golang
- Language: Go
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simple REST API using GO
## Requirements
- [go 1.11 or latest](https://golang.org/doc/install)
- [dep](https://golang.github.io/dep/)## Dependencies
- [gin](https://github.com/gin-gonic/gin)
- [gorm](https://github.com/jinzhu/gorm)
- [sqlite3](https://github.com/mattn/go-sqlite3)## Install
- `make install-deb`## Build
- `make build`
thats will be generate 3 binary file for _linux, macos, windows_ in `./build`
or you can specified build using below command :
```
make build-linux
make build-darwin
make build-windows
```## Run
- `make run` or you can run the binary file in `./build` directory after build success## Documentation
* `BASE_URL=http://localhost:3000`
* `GET` `/products` _get all persons_response example
```json
{
"code": 200,
"data": [
{
"id": 1,
"FirstName": "",
"LastName": "",
"Avatar": "",
"Age": 0
},
{
"id": 2,
"FirstName": "",
"LastName": "",
"Avatar": "https://api.adorable.io/avatars/120/jarjitsingh.png",
"Age": 10
},
{
"id": 3,
"FirstName": "jarjit",
"LastName": "singh",
"Avatar": "https://api.adorable.io/avatars/120/jarjitsingh.png",
"Age": 10
}
],
"msg": "success"
}
```* `GET` `/persons/{id}` _get person by id_
response example
```json
{
"code": 200,
"msg": "Success",
"data": {
"id": 4,
"FirstName": "jarjit",
"LastName": "singh",
"Avatar": "https://api.adorable.io/avatars/120/jarjitsingh.png",
"Age": 10
}
}
```* `POST` `/persons` _insert person data_
request example
```json
{
"firstname":"jarjit",
"lastname":"singh",
"avatar":"https://api.adorable.io/avatars/120/jarjitsingh.png",
"age":10
}
```response example
```json
{
"code": 200,
"data": {
"id": 4,
"FirstName": "jarjit",
"LastName": "singh",
"Avatar": "https://api.adorable.io/avatars/120/jarjitsingh.png",
"Age": 10
},
"msg": "success"
}
```