Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/piyush1146115/go-rest-api-with-cli
https://github.com/piyush1146115/go-rest-api-with-cli
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/piyush1146115/go-rest-api-with-cli
- Owner: piyush1146115
- License: apache-2.0
- Created: 2021-03-15T10:30:49.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-03-22T05:40:57.000Z (almost 2 years ago)
- Last Synced: 2024-11-12T02:08:24.069Z (3 months ago)
- Language: Go
- Size: 23 MB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# REST API Server in Golang
- This API server provides endpoints to create,read,update & delete sample articles.
## To Start API Server
```$ git clone https://github.com/piyush1146115/Go-REST-API-with-CLI.git``````$ cd Go-REST-API-with-CLI```
```$ go install```
```$ Go-REST-API-with-CLI version``` [print the version of the api server]
```$ Go-REST-API-with-CLI startserver``` [run the api server]
## Command to run unit test for API endpoints
```$ cd api``````$ go test```
## Commands to run API server in docker container
```shell
$ docker build -t .
$ docker run -p 8080:8080 # to start the server with default config
```## Data Model
- User Model
```
type Article struct {
Id string `json: "Id"`
Title string `json:"Title"`
Desc string `json:"desc"`
Content string `json:"content"`
}
```## Available API Endpoints
| Method | API Endpoint | Description |
|---|---|---|
|GET| /article/{id} | Return an article having the given id|
|GET| /articles | Returns all the articles|
|POST| /article | Add a new article |
|PUT| /article/{id} | Update an article with the given ID|
|DELETE| /article/{id} | Delete the article with the respective ID|## Available Flags
| Flag | Shorthand | Default value | Example | Description
|---|---|---|---|---|
|port|p|8080| Go-REST-API-with-CLI start --port=8090 | Start API server in the given port otherwise in default port