...

Package utils

import "github.com/chaos-mesh/chaos-mesh/pkg/dashboard/apiserver/utils"
Overview
Index

Overview ▾

Variables

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
)
var (
    ResponseSuccess = Response{Status: "success"}
)

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)

type APIError

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

type MapStringSliceResponse

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

type MapStringSliceResponse map[string][]string

type Response

Response defines a common status struct.

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