sdk_utils

package
v0.0.0-...-693654f Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CustomStatusCodeMessages = MapStatusCodeMessages{
	404: "resource is missing",
	401: "authentication failed",
}

CustomStatusCodeMessages is looked up with a status code for custom responses. Add your custom messages here instead of creating if statements in the ionoscloud package

Functions

func SanitizeStatusCode

func SanitizeStatusCode(statusCode int, message string) error

SanitizeStatusCode calls SanitizeStatusCodeCustom with some default customized messages. Refer to its documentation for behaviour

func SanitizeStatusCodeCustom

func SanitizeStatusCodeCustom(statusCode int, message string, mapOfCustomResponses MapStatusCodeMessages) error

SanitizeStatusCodeCustom is responsible for breaking execution if the response passed as a parameter has a bad status code (i.e. >299). Refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/Status for types of HTTP codes. If a custom response is found, but the response code is valid (<300), then we log the response using the validCodeLogFunc param.

func ShortenOpenApiErr

func ShortenOpenApiErr(err error) error

Types

type MapStatusCodeMessages

type MapStatusCodeMessages map[int]string

func (MapStatusCodeMessages) Has

func (m MapStatusCodeMessages) Has(k int) bool

func (MapStatusCodeMessages) Set

Jump to

Keyboard shortcuts

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