Documentation ¶
Index ¶
- func AddHeaders(req *http.Request, headers map[string]string)
- func ChanToSlice[T any](channel *chan T) []T
- func Clamp(v, min, max int64) int64
- func Contains[T any](slice []T, predicate func(T) bool) bool
- func ContainsMatch[T comparable](slice []T, value T) bool
- func Filter[T any](slice []T, predicate func(T) bool) []T
- func Find[T any](slice []T, predicate func(T) bool) (int, *T)
- func FindMatch[T comparable](slice []T, value T) (int, *T)
- func MakeJSONRequest(method, url string, body io.Reader, updateRequest ModifyReqFunc) (*http.Response, error)
- func Map[T any, U any](slice []T, mapFn func(T) U) []U
- func NoMod(req *http.Request) error
- func PFalse() *bool
- func PTrue() *bool
- func Ptr[T any](t T) *T
- func SprintfPtr(s string, vals ...any) *string
- func StrToLowerCaseUnderscore(str string) string
- func StrToUpperCaseUnderscore(str string) string
- type ModifyReqFunc
- type TimelineFilters
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddHeaders ¶
AddHeaders adds headers to a request pre-flight
func ChanToSlice ¶
func ChanToSlice[T any](channel *chan T) []T
ChanToSlice is a generic function that converts a buffered channel into a slice. This consumes the channel in the process.
func Clamp ¶
Clamp is a small helper that ensures that a given number v lies between bounds m, n. If it is outside of those bounds, it sets v to the closer of (m, n)
func ContainsMatch ¶
func ContainsMatch[T comparable](slice []T, value T) bool
ContainsMatch is an optimization on Contains that restricts checks to comparable elements.
func Filter ¶
Filter is a generic function that searches through a list searching for all items that match the given predicate. This returns the elements that matched the predicate in the order they were encountered.
func Find ¶
Find is a generic function that searches through a list searching for an item that matches the given predicate. If found, returns the index where it was found, and a pointer to the actual data. If not found, return (-1, nil) Note: the search is sequential, but terminated once the element is found
func FindMatch ¶
func FindMatch[T comparable](slice []T, value T) (int, *T)
FindMatch is a minor optimization of Find that restricts finds to only comparable elements.
func MakeJSONRequest ¶
func MakeJSONRequest(method, url string, body io.Reader, updateRequest ModifyReqFunc) (*http.Response, error)
MakeJSONRequest makes a request with the content-type application/json, and an optional body
func Map ¶
Map is a generic function that converts a list of type T into a list of type U, along with a function that converts a T to a U. This is essentially the same as a `map` function in other languages, like javascript
func Ptr ¶
func Ptr[T any](t T) *T
Ptr is a small helper to convert a real value into a pointer to that value. Most useful as a way to turn a literal into a pointer to that literal
func SprintfPtr ¶
SprintfPtr is a wrapper around Sprintf that returns the result as a string pointer
Types ¶
type ModifyReqFunc ¶
type TimelineFilters ¶
type TimelineFilters struct { UUID filter.Values Text []string Metadata []string Tags filter.Values Type filter.Values Operator filter.Values DateRanges filter.DateValues WithEvidenceUUID filter.Values Linked *bool SortAsc bool }
TimelineFilters represents all of the parsed timeline configuraions
func ParseTimelineQuery ¶
func ParseTimelineQuery(query string) (TimelineFilters, error)
ParseTimelineQuery parses a query a user may type into the search box on the timeline page into a TimelineFilters struct that the events/evidence services expect