utils

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNS             = errorx.NewNamespace("error.api")
	ErrUnknown        = ErrNS.NewType("unknown")               // 500
	ErrBadRequest     = ErrNS.NewType("bad_request")           // 400
	ErrNotFound       = ErrNS.NewType("resource_not_found")    // 404
	ErrInternalServer = ErrNS.NewType("internal_server_error") // 500
	// Custom
	ErrNoClusterPrivilege   = ErrNS.NewType("no_cluster_privilege")   // 401
	ErrNoNamespacePrivilege = ErrNS.NewType("no_namespace_privilege") // 401
)
View Source
var Log = ctrl.Log.WithName("apiserver")
View Source
var (
	ResponseSuccess = Response{Status: "success"}
)

Functions

func AuthMiddleware

func AuthMiddleware(c *gin.Context, config *config.ChaosDashboardConfig)

func SetAPIError

func SetAPIError(c *gin.Context, err *errorx.Error)

func SetAPImachineryError

func SetAPImachineryError(c *gin.Context, err error)

func ShouldBindBodyWithJSON

func ShouldBindBodyWithJSON(c *gin.Context, obj interface{}) (err error)

Types

type APIError

type APIError struct {
	Code     int    `json:"code"`
	Type     string `json:"type"`
	Message  string `json:"message"`
	FullText string `json:"full_text"`
}

type MapStringSliceResponse

type MapStringSliceResponse map[string][]string

MapSliceResponse is an alias of map[string][]string.

type Response

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

Response defines a common status struct.

Jump to

Keyboard shortcuts

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