Documentation
      ¶
    
    
  
    
  
    Index ¶
- Variables
 - func IsNotFoundError(err error) bool
 - type Response
 - func BadRequest(err error) Response
 - func Forbidden(err error) Response
 - func InternalError(err error) Response
 - func NotFound(err error) Response
 - func NotImplemented(err error) Response
 - func PreconditionFailed(err error) Response
 - func SmartError(err error) Response
 - func SyncResponse(success bool, metadata any) Response
 - func SyncResponseETag(success bool, metadata any, etag any) Response
 - func SyncResponseLocation(success bool, metadata any, location string) Response
 - func Unauthorized(err error) Response
 - func Unavailable(err error) Response
 
Constants ¶
This section is empty.
Variables ¶
var EmptySyncResponse = &syncResponse{success: true, metadata: make(map[string]any)}
    EmptySyncResponse represents an empty syncResponse.
Functions ¶
func IsNotFoundError ¶
IsNotFoundError returns true if the error is considered a Not Found error.
Types ¶
type Response ¶
type Response interface {
	Render(w http.ResponseWriter) error
	String() string
	Code() int
}
    Response represents an API response.
func BadRequest ¶
BadRequest returns a bad request response (400) with the given error.
func InternalError ¶
InternalError returns an internal error response (500) with the given error.
func NotImplemented ¶
NotImplemented returns a not implemented response (501) with the given error.
func PreconditionFailed ¶
PreconditionFailed returns a precondition failed response (412) with the given error.
func SmartError ¶
SmartError returns the right error message based on err. It uses the stdlib errors package to unwrap the error and find the cause.
func SyncResponse ¶
SyncResponse returns a new syncResponse with the success and metadata fields set to the provided values.
func SyncResponseETag ¶
SyncResponseETag returns a new syncResponse with an etag.
func SyncResponseLocation ¶
SyncResponseLocation returns a new syncResponse with a location.
func Unauthorized ¶
Unauthorized return an unauthorized response (401) with the given error.
func Unavailable ¶
Unavailable return an unavailable response (503) with the given error.