Categorygithub.com/piyush1146115/Go-REST-API-with-CLI
modulepackage
0.0.0-20230322054057-e93b2d2d1f0a
Repository: https://github.com/piyush1146115/go-rest-api-with-cli.git
Documentation: pkg.go.dev

# 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

$ docker build -t <image_name> .
$ docker run -p 8080:8080 <given_image_name> # 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

MethodAPI EndpointDescription
GET/article/{id}Return an article having the given id
GET/articlesReturns all the articles
POST/articleAdd 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

FlagShorthandDefault valueExampleDescription
portp8080Go-REST-API-with-CLI start --port=8090Start API server in the given port otherwise in default port

# Packages

No description provided by the author
Copyright © 2021 NAME HERE <EMAIL ADDRESS> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.