apis

package
v0.0.0-...-e70fe5d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Packave api provides functions which are used to serve the http Endpoints

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPair

func GetPair(response http.ResponseWriter, request *http.Request)

GetPair fetches a key-value pair from in-memory database

func GetRecords

func GetRecords(response http.ResponseWriter, request *http.Request)

GetRecords Rest Endpoint to fetches records from database

func HandlePair

func HandlePair(response http.ResponseWriter, request *http.Request)

Handle Pair common REST endpoint for GetPair and InsertPair

func InsertPair

func InsertPair(response http.ResponseWriter, request *http.Request)

InsertPairs creates a key-value entry in in-memory database

Types

type ErrorResponse

type ErrorResponse struct {
	StatusCode   int    `json:"status"`
	ErrorMessage string `json:"message"`
}

ErrorResponse to be sent back for any errors in the system

type RecordRequest

type RecordRequest struct {
	StartDate string `validate:"required" json:"startdate"`
	EndDate   string `validate:"required" json:"enddate"`
	MinCount  int    `validate:"required" json:"mincount"`
	MaxCount  int    `validate:"required" json:"maxcount"`
}

Request representing GetRecords input structure, includes validation and json tags

type RecordResponse

type RecordResponse struct {
	Code    int             `json:"code"`
	Msg     string          `json:"msg"`
	Records []models.Record `json:"records"`
}

RecordResponse to be sent back on GetRecords request

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL