package
7.0.1+incompatible
Repository: https://github.com/apache/trafficcontrol.git
Documentation: pkg.go.dev
# Functions
AddLastModifiedHdr adds the "last modified" header to the response.
No description provided by the author
AllParams takes the request (in which the router has inserted context for path parameters), and an array of parameters required to be integers, and returns the map of combined parameters, and the map of int parameters; or a user or system error and the HTTP error code.
CheckIfUnModified checks to see if the resource was modified since the "If-Unmodified-Since" header value in the request.
CheckIfUnModifiedByName checks to see if the resource was modified since the "If-Unmodified-Since" header value in the request.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
CreateDeprecationAlerts creates a deprecation notice with an optional alternative route suggestion.
CreateHandler creates a handler function from the pointer to a struct implementing the Creator interface this generic handler encapsulates the logic for handling: *current user *decoding and validating the struct *change log entry *forming and writing the body over the wire.
DefaultSort sorts alphabetically for a given readerType (eg: TOCDN, TODeliveryService, TOOrigin etc).
DeleteHandler creates a handler function from the pointer to a struct implementing the Deleter interface this generic handler encapsulates the logic for handling: *fetching the id from the path parameter *current user *change log entry *forming and writing the body over the wire.
DeprecatedDeleteHandler creates a handler function from the pointer to a struct implementing the Deleter interface with a optional deprecation notice this generic handler encapsulates the logic for handling: *fetching the id from the path parameter *current user *change log entry *forming and writing the body over the wire.
DeprecatedReadHandler creates a net/http.HandlerFunc for the passed Reader object, and adds a deprecation notice, optionally with a passed alternative route suggestion.
FormatLastModified trims the time string and formats it according to RFC1123.
GenericCreate does a Create (POST) for the given GenericCreator object and type.
GenericCreateNameBasedID does a Create (POST) for the given GenericCreator object and type.
GenericDelete does a Delete (DELETE) for the given GenericDeleter object and type.
GenericOptionsDelete does a Delete (DELETE) for the given GenericOptionsDeleter object and type.
No description provided by the author
GenericUpdate handles the common update case, where the update returns the new last_modified time.
GetAsyncStatus returns the status of an asynchronous job.
No description provided by the author
No description provided by the author
GetDB returns the database from the context.
No description provided by the author
GetLastUpdated checks for the resource by ID in the database, and returns its last_updated timestamp, if available.
GetLastUpdatedByName checks for the resource by name in the database, and returns its last_updated timestamp, if available.
No description provided by the author
GetRequestedAPIVersion returns a pointer to the requested API Version from the request if it exists or returns nil otherwise.
No description provided by the author
No description provided by the author
GetUserFromReq returns the current user, any user error, any system error, and an error code to be returned if either error was not nil.
GoneHandler is an http.Handler function that just writes a 410 Gone response back to the client, along with an error-level alert stating that the endpoint is no longer available.
HandleDeprecatedErr handles an API error, adding a deprecation alert, rolling back the transaction, writing the given statusCode and userErr to the user, and logging the sysErr.
HandleErr handles an API error, rolling back the transaction, writing the given statusCode and userErr to the user, and logging the sysErr.
No description provided by the author
InsertAsyncStatus inserts a new status for an asynchronous job.
IntParams parses integer parameters, and returns map of the given params, or an error if any integer param is not an integer.
No description provided by the author
No description provided by the author
IsUnmodified returns a boolean, saying whether or not the resource in question was modified since the time specified in the headers.
LogErr handles the logging of errors and setting up possibly nil errors without actually writing anything to a http.ResponseWriter, unlike handleSimpleErr.
No description provided by the author
NewInfo get and returns the context info needed by handlers.
ParamsHaveRequired checks that params have all the required parameters, and returns nil on success, or an error providing information on which params are missing.
Parse decodes a JSON object from r into v, validating and sanitizing the input.
ParseDBError parses pq errors for database constraint violations, and returns the (userErr, sysErr, httpCode) format expected by the API helpers.
ReadHandler creates a handler function from the pointer to a struct implementing the Reader interface this handler retrieves the user from the context combines the path and query parameters produces the proper status code based on the error code returned marshals the structs returned into the proper response json.
RespWriter is a helper to allow a one-line response, for endpoints with a function that returns the object that needs to be written and an error.
RespWriterVals is like RespWriter, but also takes a map of root-level values to write.
SendEmailFromTemplate allows a user to input an html template to format an email.
SendMail sends an email msg to the address identified by to.
SetLastModifiedHeader sets the Last-Modified header in case the "useIMS" is set to true in the config, and if there is an "If-Modified-Since" header in the incoming request.
StripParamJSON removes ".json" trailing any parameter value, and returns the modified params.
TryIfModifiedSinceQuery checks to see the max time that an entity was changed, and then returns a boolean (which tells us whether or not to run the main query for the endpoint) along with the max time If the returned boolean is false, there is no need to run the main query for the GET API endpoint, and we return a 304 status.
UpdateAsyncStatus updates the status table for an asynchronous job.
UpdateHandler creates a handler function from the pointer to a struct implementing the Updater interface this generic handler encapsulates the logic for handling: *fetching the id from the path parameter *current user *decoding and validating the struct *change log entry *forming and writing the body over the wire.
No description provided by the author
No description provided by the author
WriteAndLogErr writes the response and logs a warning if an error occurs.
WriteIMSHitResp writes a response to 'w' for an IMS request "hit", using the passed time as the Last-Modified date.
WriteResp takes any object, serializes it as JSON, and writes that to w.
WriteRespAlert creates an alert, serializes it as JSON, and writes that to w.
WriteRespAlertNotFound creates an alert indicating that the resource was not found and writes that to w.
WriteRespAlertObj Writes the given alert, and the given response object.
WriteRespRaw acts like WriteResp, but doesn't wrap the object in a `{"response":` object.
WriteRespVals is like WriteResp, but also takes a map of root-level values to write.
WriteRespWithSummary writes a JSON-encoded representation of an arbitrary object to the provided writer, and cleans up the corresponding request object.
# Constants
No description provided by the author
No description provided by the author
Common context.Context value keys.
No description provided by the author
No description provided by the author
No description provided by the author
Common context.Context value keys.
No description provided by the author
No description provided by the author
Common context.Context value keys.
No description provided by the author
No description provided by the author
NilRequestError is returned by APIInfo methods when the request internally referred to by the APIInfo cannot be found.
NilTransactionError is returned by APIInfo methods when the transaction internally referred to by the APIInfo cannot be found.
Common context.Context value keys.
Common context.Context value keys.
ResourceModifiedError is a user-safe error that indicates a precondition failure.
Common context.Context value keys.
No description provided by the author
# Structs
No description provided by the author
APIInfoImpl implements APIInfo via the APIInfoer interface.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
No description provided by the author
APIInfoer is an interface that guarantees the existance of a variable through its setters and getters.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
GenericOptionsDeleter can use any key listed in DeleteKeyOptions() to delete a resource.
No description provided by the author
No description provided by the author
No description provided by the author
MultipleCreator indicates whether an object using the shared handlers allows an array of objects in the POST.
OptionsDeleter calls the OptionsDelete() generic CRUD function, unlike Deleter, which calls Delete().
ParseValidator objects can make use of api.Parse to handle parsing and validating at the same time.
No description provided by the author
No description provided by the author
No description provided by the author
Validator objects return user and system errors based on validation rules defined by that object.