handlers

package
v0.0.0-...-3a58fe4 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package handlers controls network routing and rate limiter for each route

Index

Constants

View Source
const APIURL string = "http://pr-service:30000"

APIURL is downstream proxy to run inference

Variables

This section is empty.

Functions

func Health

func Health(w http.ResponseWriter, r *http.Request)

Health returns status of proxy and model health

func NewAttributesHandler

func NewAttributesHandler(r *mux.Router, s models.AttributesServices)

NewAttributesHandler is responsible to routing handler services

func NewProductsHandler

func NewProductsHandler(r *mux.Router, s models.ProductsServices)

NewProductsHandler defines new handlers for products

func POSTDownstream

func POSTDownstream(w http.ResponseWriter, r *http.Request, b *bytes.Buffer)

POSTDownstream writes reponses body into []bytes and sends it downstream

func ResponseJSON

func ResponseJSON(w http.ResponseWriter, code int, payload interface{})

ResponseJSON processes normal JSON responses

Types

type AttributesHandler

type AttributesHandler struct {
	// contains filtered or unexported fields
}

AttributesHandler ...

func (*AttributesHandler) FetchAllAttributes

func (a *AttributesHandler) FetchAllAttributes(w http.ResponseWriter, r *http.Request)

FetchAllAttributes returns all attributes and send downstream to sort product in order of importance

type AttributesResponse

type AttributesResponse struct {
	Code    int                 `json:"code"`
	Payload []models.Attributes `json:"attributes"`
	Message string              `json:"message"`
}

AttributesResponse model

type HealthStatus

type HealthStatus struct {
	ProxyAlive  bool `json:"ProxyAlive"`
	StreamAlive bool `json:"StreamAlive"`
}

HealthStatus defines connection of inner proxy

type ProductResponse

type ProductResponse struct {
	// in:body
	Payload *models.Products `json:"product"`
}

ProductResponse model

type ProductsHandler

type ProductsHandler struct {
	// contains filtered or unexported fields
}

ProductsHandler ...

func (*ProductsHandler) FetchAllProducts

func (p *ProductsHandler) FetchAllProducts(w http.ResponseWriter, r *http.Request)

FetchAllProducts sends table information downstream to generate corpus

func (*ProductsHandler) FetchCSV

func (p *ProductsHandler) FetchCSV(w http.ResponseWriter, r *http.Request)

FetchCSV returns a csv file of product_info

func (*ProductsHandler) GetByID

func (p *ProductsHandler) GetByID(w http.ResponseWriter, r *http.Request)

GetByID will send product_info downstream for inference

type ProductsResponse

type ProductsResponse struct {
	Code    int               `json:"code"`
	Payload []models.Products `json:"products"`
	Message string            `json:"message"`
}

ProductsResponse model

Jump to

Keyboard shortcuts

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