Documentation ΒΆ
Overview ΒΆ
Package toolbox does not currently implement any functionality. The subfolders within this package provide the full functionality of the toolbox.
Any method in the toolbox which returns an error object will return a custom error type implementing the go.imperva.dev/toolbox/errors.ExtendedError interface. The specific errors returned by the method are noted in its documentation. Each integer code corresponding the the specific error is unique across the entire toolbox.
To determine the specific type of error that was returned, you can use 1 of 3 methods:
β½ Use the errors.Is() method with new(ErrType) as the second argument where ErrType is the actual type of error that is expected. β½ Use the errors.As() method to determine if you can convert the error into the given object. The advantage of this method is that you can then also access each error's custom fields. β½ Cast the error object to an ExtendedError object and then use the Code() method to compare the error code to the corresponding error code constant defined as the error type with 'Code' appended to it (eg: ErrDoRequestFailureCode, ErrResourceWaitFailureCode)
Logging for methods within the toolbox is performed using either the zerolog logger object supplied in the context parameter for the method (generated by calling the logger instance's WithContext() function) or the global zerlog logger unless otherwise noted in the method's documentation.
The following error codes are allocated for each package:
β½ collection: 1001-1250 β½ crypto: 1251-1500 β½ gin: 2751-3000 β½ gin/api: 3001-3250 β½ gin/context: 3251-3500 β½ gin/middleware: 3501-3750 β½ i18n: 1501-1750 β½ k8s: 1751-2000 β½ net: 2001-2250 β½ net/http: 2251-2500 β½ strings: 2501-2750
Directories ΒΆ
Path | Synopsis |
---|---|
Package collection contains utility functions to help deal with collections such as maps and slices.
|
Package collection contains utility functions to help deal with collections such as maps and slices. |
Package crypto contains functionality for dealing with X509 certificates and cryptography.
|
Package crypto contains functionality for dealing with X509 certificates and cryptography. |
Package errors provides simple error handling primitives.
|
Package errors provides simple error handling primitives. |
Package gin contains additional functionality for the gin-gonic framework.
|
Package gin contains additional functionality for the gin-gonic framework. |
api
Package api contains useful objects and methods to use with APIs.
|
Package api contains useful objects and methods to use with APIs. |
context
Package context contains additional functionality related to the gin-gonic context.
|
Package context contains additional functionality related to the gin-gonic context. |
middleware
Package middleware contains a collection of middleware for use with gin-gonic.
|
Package middleware contains a collection of middleware for use with gin-gonic. |
Package i18n handles text and data translation based on various locales.
|
Package i18n handles text and data translation based on various locales. |
Package k8s handles interacting with Kubernetes clusters.
|
Package k8s handles interacting with Kubernetes clusters. |
Package net deals with networking-related functionality.
|
Package net deals with networking-related functionality. |
http
Package http handles interacting with HTTP clients and servers.
|
Package http handles interacting with HTTP clients and servers. |
Package strings contains helper functions related to string management.
|
Package strings contains helper functions related to string management. |