rest_handlers

package
v0.0.0-...-d4d4b81 Latest Latest
Warning

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

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

Documentation

Overview

Package rest_handlers provides rest handlers

Index

Constants

This section is empty.

Variables

View Source
var GetIconHandler = gin.HandlerFunc(func(c *gin.Context) {
	replacer := strings.NewReplacer("..", "", "../", "", "/", "", "\\", "")
	var (
		projectID          = replacer.Replace(c.Param("ProjectID"))
		hubName            = replacer.Replace(c.Param("HubName"))
		chartName          = replacer.Replace(c.Param("ChartName"))
		iconName           = replacer.Replace(c.Param("IconName"))
		img                *os.File
		err                error
		responseStatusCode = http.StatusOK
	)

	if strings.ToLower(chartName) == "predefined" {
		img, err = os.Open("/tmp/version/" + projectID + "/" + hubName + "/workflows/icons/" + iconName)
	} else {
		img, err = os.Open("/tmp/version/" + projectID + "/" + hubName + "/charts/" + chartName + "/icons/" + iconName)
	}

	if err != nil {
		responseStatusCode = http.StatusInternalServerError
		fmt.Fprint(c.Writer, "icon cannot be fetched, err : "+err.Error())
	}

	defer img.Close()

	c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
	c.Writer.WriteHeader(responseStatusCode)
	c.Writer.Header().Set("Content-Type", "image/png")
	io.Copy(c.Writer, img)
})

GetIconHandler ...

Functions

func FileHandler

func FileHandler(mongodbOperator mongodb.MongoOperator, kubeClients *k8s.KubeClients) gin.HandlerFunc

FileHandler dynamically generates the manifest file and sends it as a response

func LoggingMiddleware

func LoggingMiddleware() gin.HandlerFunc

LoggingMiddleware is a middleware that logs the request as it goes in and the response as it goes out.

func PlaygroundHandler

func PlaygroundHandler() gin.HandlerFunc

PlaygroundHandler returns GraphQL playground ui

func ReadinessHandler

func ReadinessHandler(mongoClient *mongo.Client, mongodbOperator mongodb.MongoOperator) gin.HandlerFunc

ReadinessHandler returns current status of this application

func StatusHandler

func StatusHandler(c *gin.Context)

StatusHandler returns current status of this application

func WorkflowHelperImageVersionHandler

func WorkflowHelperImageVersionHandler(c *gin.Context)

WorkflowHelperImageVersionHandler is used to provide workflow helper's image version

Types

type APIStatus

type APIStatus struct {
	Status string `json:"status"`
}

type ReadinessAPIStatus

type ReadinessAPIStatus struct {
	DataBase    string `json:"database"`
	Collections string `json:"collections"`
}

type WorkflowHelperImageVersion

type WorkflowHelperImageVersion struct {
	Version string `json:"version"`
}

Jump to

Keyboard shortcuts

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