Documentation
¶
Index ¶
- Constants
- Variables
- func MetricMiddleware() gin.HandlerFunc
- func MetricRegister(registerer prometheus.Registerer)
- func MetricRegisterOn(registerer prometheus.Registerer)
- func MetricUnRegister(registerer prometheus.Registerer)
- func MetricUnRegisterFrom(registerer prometheus.Registerer)
- type Controller
- type NvdController
- type NvdDB
- type Options
- type Server
Constants ¶
const ( APIGroupNVD = "/nvd" APIPathGetCVE = "/cve" APIPathGetCPE = "/cpe" APIPathReady = "/readiness" // Status... are variables that shows the status for API // Since api returns 200 for both 'found' and 'not_found' instead of 404, // it should be another field to inform the status from DB StatusFound = "found" StatusNotFound = "not_found" StatusError = "error" // Qs... are keys of query string that are valid for API QsCveId = "cveId" QsCpeName = "cpeName" QsCpeMatchStr = "cpeMatchString" QsKeyword = "keywordSearch" QsKeywordExact = "keywordExactMatch" QsStartIndex = "startIndex" QsResultsPerPage = "resultsPerPage" )
const ( // CVEResultsPerPage is the default resultsPerPage for NVD CVE API CVEResultsPerPage = 2000 // CPEResultsPerPage is the default resultsPerPage for NVD CPE API // The document declares with 5000 while it is actually 10000 CPEResultsPerPage = 10000 )
Variables ¶
var ( // CVEQSKeys is the keys of query string. It's expected to provide one of them for CVE API CVEQSKeys = []string{QsCveId, QsCpeName, QsKeyword} // CPEQSKeys is the keys of query string. It's expected to provide one of them for CPE API CPEQSKeys = []string{QsCpeMatchStr, QsCpeName, QsKeyword} )
var ErrStop = errors.New("stop server")
Functions ¶
func MetricMiddleware ¶
func MetricMiddleware() gin.HandlerFunc
func MetricRegister ¶
func MetricRegister(registerer prometheus.Registerer)
MetricRegister register metrics when server starts
func MetricRegisterOn ¶
func MetricRegisterOn(registerer prometheus.Registerer)
MetricRegisterOn register needed promutheus metrics on given registerer
func MetricUnRegister ¶
func MetricUnRegister(registerer prometheus.Registerer)
MetricUnRegister unregister metrics when server shutdown
func MetricUnRegisterFrom ¶
func MetricUnRegisterFrom(registerer prometheus.Registerer)
MetricUnRegisterFrom unregister metrics from registerer
Types ¶
type Controller ¶
type Controller interface {
Register(*gin.RouterGroup, ...gin.HandlerFunc)
}
Controller is the interface to implement a router group which is registered to *gin.Engine with Register function
type NvdController ¶
type NvdController struct {
// contains filtered or unexported fields
}
NvdController is the controller to handle requests from asking NVD information
func NewNvdController ¶
func NewNvdController(subGrpName string, dbCli NvdDB) (*NvdController, error)
NewNvdController initializes controller, and the return instance provides what the handler needs (E.g., db and queue client)
func (NvdController) Register ¶
func (h NvdController) Register(grp *gin.RouterGroup, hdlFuncs ...gin.HandlerFunc)
Register implements Controller interface to register group of Routes to gin Engine
type Options ¶
func AccessLogger ¶
func Controllers ¶
func Controllers(cs ...Controller) Options
func ErrorLogger ¶
func Registry ¶
func Registry(reg *prometheus.Registry) Options
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) FullyStopped ¶
func (s *Server) FullyStopped()
FullyStopped wait for server to be fully killed, which is use in testing to avoid data race in metrics