Documentation ¶
Overview ¶
Package handlers controls network routing and rate limiter for each route
Index ¶
- Constants
- func DocHandler(w http.ResponseWriter, r *http.Request)
- func Health(w http.ResponseWriter, r *http.Request)
- func NewAttributesHandler(r *mux.Router, s models.AttributesServices)
- func NewProductsHandler(r *mux.Router, s models.ProductsServices)
- func POSTDownstream(w http.ResponseWriter, r *http.Request, b *bytes.Buffer)
- func ResponseJSON(w http.ResponseWriter, code int, payload interface{})
- type AttributesHandler
- type AttributesResponse
- type HealthStatus
- type ProductResponse
- type ProductsHandler
- type ProductsResponse
Constants ¶
const APIURL string = "http://pr-service:30000"
APIURL is downstream proxy to run inference. dev: "http://0.0.0.0:5000"
Variables ¶
This section is empty.
Functions ¶
func DocHandler ¶
func DocHandler(w http.ResponseWriter, r *http.Request)
DocHandler handles swagger json file
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 ¶
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 ¶
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