utils

package
v0.0.0-...-54a0447 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureAndRecover

func CaptureAndRecover(w http.ResponseWriter, r *http.Request, endpoint string)

CaptureAndRecover is deffered in a function to prevent panics from crashing the API server. Every API endpoint should have this function deffered to avoid crashes.

func ClientIP

func ClientIP(r *http.Request) string

ClientIP returns the client IP forwarded by Cloudflare.

func EndpointError

func EndpointError(r *http.Request, err *errors.APIError, endpoint string)

EndpointError is used when a certain API endpoint encounters an error. This function will log the error, and report the error to Sentry as well. However, the error will not be logged or reported if the error is because of a "user fault" (e.g - the DB cannot find a key in the database, but is able to query it)

func EndpointWarning

func EndpointWarning(r *http.Request, endpoint, msg string)

EndpointWarning is used when a certain API endpoint wants to log a warning. These warnings should be used when there is an invalid request, or a rejected request.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL