Documentation ¶
Index ¶
- Variables
- func CheckPermissions(writer http.ResponseWriter, request *http.Request, orgID types.OrgID, ...) bool
- func CreateOpenAPIHandler(filePath string, debug bool, cacheFile bool) func(writer http.ResponseWriter, request *http.Request)
- func FilterOutDebugMethods(openAPIFileContent string) (string, error)
- func GetRouterParam(request *http.Request, paramName string) (string, error)
- func GetRouterPositiveIntParam(request *http.Request, paramName string) (uint64, error)
- func HandleOrgIDError(writer http.ResponseWriter, err error)
- func LogRequest(nextHandler http.Handler) http.Handler
- func MakeURLToEndpoint(apiPrefix, endpoint string, args ...interface{}) string
- func MakeURLToEndpointMap(apiPrefix, endpoint string, args map[string]interface{}) string
- func MakeURLToEndpointMapString(apiPrefix, endpoint string, args map[string]string) string
- func ReadClusterListFromBody(writer http.ResponseWriter, request *http.Request) ([]string, bool)
- func ReadClusterListFromPath(writer http.ResponseWriter, request *http.Request) ([]string, bool)
- func ReadClusterName(writer http.ResponseWriter, request *http.Request) (types.ClusterName, bool)
- func ReadClusterNames(writer http.ResponseWriter, request *http.Request) ([]types.ClusterName, bool)
- func ReadErrorKey(writer http.ResponseWriter, request *http.Request) (types.ErrorKey, bool)
- func ReadOrganizationID(writer http.ResponseWriter, request *http.Request, auth bool) (types.OrgID, bool)
- func ReadOrganizationIDs(writer http.ResponseWriter, request *http.Request) ([]types.OrgID, bool)
- func ReadRuleID(writer http.ResponseWriter, request *http.Request) (types.RuleID, bool)
- func ReadRuleSelector(writer http.ResponseWriter, request *http.Request) (types.RuleSelector, bool)
- func ReplaceParamsInEndpointAndTrimLeftSlash(endpoint, replacer string) string
- func SplitRequestParamArray(arrayParam string) []string
- func ValidateClusterName(clusterName string) (types.ClusterName, error)
Constants ¶
This section is empty.
Variables ¶
var ( //RuleIDValidator points to a Regexp expression that matches any // string that has alphanumeric characters separated by at least one dot // (".") RuleIDValidator = regexp.MustCompile(`^[a-zA-Z_0-9.]+$`) // RuleSelectorValidator points to a Regexp expression that matches any // string that has alphanumeric characters separated by at least one dot // (".") before a vertical line ("|"), followed by only characters, // numbers, or underscores ("_") RuleSelectorValidator = regexp.MustCompile(`[a-zA-Z_0-9]+\.[a-zA-Z_0-9.]+\|[a-zA-Z_0-9]+$`) )
Functions ¶
func CheckPermissions ¶ added in v1.6.2
func CheckPermissions(writer http.ResponseWriter, request *http.Request, orgID types.OrgID, auth bool) bool
CheckPermissions checks whether user with a provided token(from request) can access current organization and handled the error on negative result by logging the error and writing a corresponding http response
func CreateOpenAPIHandler ¶ added in v1.5.1
func CreateOpenAPIHandler(filePath string, debug bool, cacheFile bool) func(writer http.ResponseWriter, request *http.Request)
CreateOpenAPIHandler creates a handler for a server to send OpenAPI file. Optionally, you can turn on or off debug to filter out debug endpoints. Optionally, you can turn on caching by setting cacheFile to true, then you will have to restart a server on each file change
func FilterOutDebugMethods ¶ added in v1.5.1
FilterOutDebugMethods returns the same openapi spec, but without endpoints tagged as debug.
func GetRouterParam ¶ added in v1.5.0
GetRouterParam retrieves parameter from URL like `/organization/{org_id}`
func GetRouterPositiveIntParam ¶ added in v1.5.0
GetRouterPositiveIntParam retrieves parameter from URL like `/organization/{org_id}` and check it for being valid and positive integer, otherwise returns error
func HandleOrgIDError ¶ added in v1.6.2
func HandleOrgIDError(writer http.ResponseWriter, err error)
HandleOrgIDError logs org id error and writes corresponding http response
func LogRequest ¶ added in v1.3.0
LogRequest - middleware for logging requests
func MakeURLToEndpoint ¶
MakeURLToEndpoint creates URL to endpoint, use constants from file endpoints.go
func MakeURLToEndpointMap ¶ added in v1.2.3
MakeURLToEndpointMap creates URL to endpoint using arguments in map, use constants from file endpoints.go
func MakeURLToEndpointMapString ¶ added in v1.2.3
MakeURLToEndpointMapString creates URL to endpoint using arguments in map in string format, use constants from file endpoints.go
func ReadClusterListFromBody ¶ added in v1.6.5
ReadClusterListFromBody retrieves list of clusters from request's body if it's not possible, it writes http error to the writer and returns false
func ReadClusterListFromPath ¶ added in v1.6.5
ReadClusterListFromPath retrieves list of clusters from request's path if it's not possible, it writes http error to the writer and returns false
func ReadClusterName ¶
func ReadClusterName(writer http.ResponseWriter, request *http.Request) (types.ClusterName, bool)
ReadClusterName retrieves cluster name from request if it's not possible, it writes http error to the writer and returns false
func ReadClusterNames ¶ added in v1.5.0
func ReadClusterNames(writer http.ResponseWriter, request *http.Request) ([]types.ClusterName, bool)
ReadClusterNames does the same as `readClusterName`, except for multiple clusters.
func ReadErrorKey ¶ added in v1.4.1
ReadErrorKey retrieves error key from request's url or writes an error to writer. The function returns an error key and a bool indicating if it was successful.
func ReadOrganizationID ¶ added in v1.6.2
func ReadOrganizationID(writer http.ResponseWriter, request *http.Request, auth bool) (types.OrgID, bool)
ReadOrganizationID retrieves organization id from request if it's not possible, it writes http error to the writer and returns false
func ReadOrganizationIDs ¶ added in v1.6.2
ReadOrganizationIDs does the same as `readOrganizationID`, except for multiple organizations.
func ReadRuleID ¶ added in v1.4.1
ReadRuleID retrieves rule id from request's url or writes an error to writer. The function returns a rule id and a bool indicating if it was successful.
func ReadRuleSelector ¶ added in v1.21.1
func ReadRuleSelector(writer http.ResponseWriter, request *http.Request) (types.RuleSelector, bool)
ReadRuleSelector retrieves the rule selector (rule_id|error_key) from request's url or writes an error to writer. The function returns the selector and a bool indicating if it was successful.
func ReplaceParamsInEndpointAndTrimLeftSlash ¶
ReplaceParamsInEndpointAndTrimLeftSlash replaces params in endpoint and trims left slash
func SplitRequestParamArray ¶ added in v1.6.2
SplitRequestParamArray takes a single HTTP request parameter and splits it into a slice of strings. This assumes that the parameter is a comma-separated array.
func ValidateClusterName ¶ added in v1.6.2
func ValidateClusterName(clusterName string) (types.ClusterName, error)
ValidateClusterName checks that the cluster name is a valid UUID. Converted cluster name is returned if everything is okay, otherwise an error is returned.
Types ¶
This section is empty.