api

package
v0.0.0-...-a328902 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteJsonResp

func WriteJsonResp(w http.ResponseWriter, err error, respBody interface{}, status int)

use of WriteJsonRespStructured is preferable. it api exists due to historical reason err.message is used as internals message for ApiError object in resp

func WriteJsonRespStructured

func WriteJsonRespStructured(w http.ResponseWriter, err error, respBody interface{}, status int, apiErrors []*util.ApiError)

use this method when we have specific api error to be conveyed to api User

Types

type ApiError

type ApiError struct {
	HttpStatusCode    int         `json:"-"`
	Code              string      `json:"code,omitempty"`
	InternalMessage   string      `json:"internalMessage,omitempty"`
	UserMessage       interface{} `json:"userMessage,omitempty"`
	UserDetailMessage string      `json:"userDetailMessage,omitempty"`
}

type ResetRequest

type ResetRequest struct {
	AppId         int `json:"appId"`
	EnvironmentId int `json:"environmentId"`
}

type Response

type Response struct {
	Code   int         `json:"code,omitempty"`
	Status string      `json:"status,omitempty"`
	Result interface{} `json:"result,omitempty"`
	Errors []*ApiError `json:"errors,omitempty"`
}

type ResponseV2

type ResponseV2 struct {
	Code   int              `json:"code,omitempty"`
	Status string           `json:"status,omitempty"`
	Result interface{}      `json:"result,omitempty"`
	Errors []*util.ApiError `json:"errors,omitempty"`
}

global response body used across api

type RestHandler

type RestHandler interface {
	ScanForVulnerability(w http.ResponseWriter, r *http.Request)
	ScanForVulnerabilityEvent(scanConfig *common.ImageScanEvent) (*common.ScanEventResponse, error)
}

type RestHandlerImpl

type RestHandlerImpl struct {
	Logger *zap.SugaredLogger

	ImageScanService security.ImageScanService
	KlarService      klarService.KlarService
	ClairService     clairService.ClairService
	// contains filtered or unexported fields
}

func NewRestHandlerImpl

func NewRestHandlerImpl(logger *zap.SugaredLogger,
	grafeasService grafeasService.GrafeasService,
	userService user.UserService, imageScanService security.ImageScanService,
	klarService klarService.KlarService,
	clairService clairService.ClairService,
	imageScanConfig *security.ImageScanConfig) *RestHandlerImpl

func (*RestHandlerImpl) ScanForVulnerability

func (impl *RestHandlerImpl) ScanForVulnerability(w http.ResponseWriter, r *http.Request)

func (*RestHandlerImpl) ScanForVulnerabilityEvent

func (impl *RestHandlerImpl) ScanForVulnerabilityEvent(scanConfig *common.ImageScanEvent) (*common.ScanEventResponse, error)

func (*RestHandlerImpl) ScanImageAsPerTool

func (impl *RestHandlerImpl) ScanImageAsPerTool(scanConfig *common.ImageScanEvent, tool *repository.ScanToolMetadata,
	executionHistory *repository.ImageScanExecutionHistory, executionHistoryDirPath string) (*common.ScanEventResponse, error)

type Router

type Router struct {
	Router *mux.Router
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter(logger *zap.SugaredLogger, restHandler RestHandler, monitoringRouter *monitoring.MonitoringRouter) *Router

func (Router) Init

func (r Router) Init()

Jump to

Keyboard shortcuts

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