Restful Api Endpoints With Golang

REST API Endpoints

  1. records(POST) fetch data from mongodb
  2. in-memory(POST) create key value pair in-memory
  3. in-memory/:key (GET) key valeu pair from in-memory

Setup

  1. git clone https://github.com/semraince/RestfulApiWithGo.git
  2. cd RestfulApiWithGo
  3. go run main.go

Default port is 9090, it can be changed from conf.yaml

Heroku End-Points

Postman request examples can be found in GoDatabaseAssignment.postman_collection.json file

MongoDb

The request payload of the first endpoint will include a JSON with 4 fields. “startDate” and “endDate” fields will contain the date in a “YYYY-MM-DD” format. Data is filtered by using “createdAt” “minCount” and “maxCount” are for filtering the data. Sum of the “count” array in the documents should be between “minCount” and “maxCount”.

https://sleepy-hollows-06250.herokuapp.com/records
{
  "startDate": "2016-01-26",
  "endDate": "2018-02-02",
  "minCount": 2700,
  "maxCount": 3000
}
Response Payload
{
  "code":0,
  "msg":"Success",
  "records":[
    {
    "key":"TAKwGc6Jr4i8Z487",
    "createdAt":"2017-01-28T01:22:14.398Z",
    "totalCount":2800
    },
    {
    "key":"NAeQ8eX7e5TEg7oH",
    "createdAt":"2017-01-27T08:19:14.135Z",
    "totalCount":2900
    }
  ]
}
Error Responses
Status Response
502 { "msg": "Db Error Has Occured"}
503 { "msg": "Date Parse Error"}

InMemory Db

POST Request
https://sleepy-hollows-06250.herokuapp.com/in-memory

The request payload of POST endpoint will include a JSON with 2 fields. “key” fields holds the key (any key in string type) “value” fields holds the value (any value in string type)

Request Payload
{
"key": "active-tabs",
"value": "getir"
}

Response payload return echo of the request or if any error occured

GET Request
https://sleepy-hollows-06250.herokuapp.com/in-memory?key=active-tabs

The request payload of GET endpoint will include 1 query parameter. That is “key” param holds the key (any key in string type)

Response payload of GET endpoint should return a JSON with 2 fields or error in message field.

Similar Resources

A simple RESTful server with golang

A simple RESTful server Setup local development environment cp develop.env .env docker-compose up -d docker-compose exec mysql mysql -u root --passwor

Oct 28, 2021

Create a demo RESTful application using Golang

Instructions The goal of this exercise is to create a demo RESTful application using Golang. The Task In this task, we are building backend of an appl

Oct 30, 2021

Build a TodoList with Go Design and implement a backend RESTful service in golang with CRUD

May we ask Igor to do a little project in leu of sample code? If there is a hire, the hours spent should be invoiced, so please keep track of that. Th

May 5, 2022

Urlshorter - A restful url shorter for golang

To who that review this code: I try my best to dockerize files and project but I

Dec 31, 2021

BLM3 Compatible with restful interface

BLM3 Function Compatible with restful interface Compatible with influxdb v1 write interface Compatible with opentsdb json and telnet format writing Se

Dec 11, 2021

Go (Golang) API REST with Gin FrameworkGo (Golang) API REST with Gin Framework

go-rest-api-aml-service Go (Golang) API REST with Gin Framework 1. Project Description Build REST APIs to support AML service with the support of exte

Nov 21, 2021

GoTrue is a small open-source API written in Golang, that can act as a self-standing API service for handling user registration and authentication for Jamstack projects.

GoTrue is a small open-source API written in Golang, that can act as a self-standing API service for handling user registration and authentication for Jamstack projects.

GoTrue is a small open-source API written in Golang, that can act as a self-standing API service for handling user registration and authentication for Jamstack projects.

Dec 13, 2021

Fully serverless CAPTCHA API created with API Gateway, Lambda, Dynamodb and Go

Fully serverless CAPTCHA API created with API Gateway, Lambda, Dynamodb and Go

Fully serverless CAPTCHA API created with API Gateway, Lambda, Dynamodb and Go

Mar 4, 2022

Go-todo-api - An example API project written Go and Fiber Framework

This is an example API project written Go and Fiber Framework. Test codes has been written for all controller functions. Environment variables are taken from config.yml.

Jan 24, 2022
This is a small API that provides basic REST endpoints to shorten a URL
This is a small API that provides basic REST endpoints to shorten a URL

This is a small API that provides basic REST endpoints to shorten a URL, get information about the URL, update the URL, and get statistics on most accessed URLs.

Nov 16, 2021
Go-gin-mongo-api - A backend RESTful API built using golang, gin and mongoDB

go-gin-mongo-API This is a RESTful backend API which is developed using the gola

Jul 19, 2022
Rental-api - A RESTful-API that allows developers to connect to data about rental properties

Rentals-API is a RESTful-API that allows developers to connect to data about rental properties.

Jan 24, 2022
Gin-easy-todo - golang 의 RESTful API 프레임워크 gin 을 활용해 아주 간단한 Todo 애플리케이션을 만들어보자.
Gin-easy-todo - golang 의 RESTful API 프레임워크 gin 을 활용해 아주 간단한 Todo 애플리케이션을 만들어보자.

목차 1. 요약 2. 목표 3. API 목록 4. 프로젝트 구조 5. 패키지 별 기능과 관계 6. 사전 작업 6.1. DB, Table 생성 6.2. 모듈 생성 6.3. 패키지 다운로드 7. Gin 작성 7.1. 데이터베이스 설정 7.2. 테이블, 스키마 정의 7.3.

Jan 2, 2022
A RESTful API written in Golang to store and retrieve ticket information.

Tickets-API A RESTful API written in Golang to store and retrieve ticket information. This is a RESTful API built on top of the gin-gonic/gin package

Jan 31, 2022
A restful api's with Gin Framework with a structured project that defaults to PostgreSQL database
A restful api's with Gin Framework with a structured project that defaults to PostgreSQL database

Welcome to Golang Gin boilerplate v2 The fastest way to deploy a restful api's with Gin Framework with a structured project that defaults to PostgreSQ

Oct 15, 2021
Restful API example with using go and gin framework

simple device api Simple Device API is really simple and concise to show how easy to implement a Restful Service with using Golang. It uses gin framew

Nov 18, 2021
A simple RESTful API for storing and retrieving data during MRI image reconstructions

MRD Storage Server The MRD Storage Server provides a simple RESTful API for storing and retrieving data during MRI image reconstructions. It supports:

Mar 18, 2022
Tutorial: Developing a RESTful API with Go and Gin

Tutorial: Developing a RESTful API with Go and Gin https://go.dev/doc/tutorial/w

Jan 17, 2022
E-commerce-project - RESTFUL API for TakTuku an E-Commerce App created for the purpose of study

About The Project RESTFUL API for TakTuku an E-Commerce App created for the purp

Jul 23, 2022