utils

package
v0.0.42 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger = shared.ProvideLogger(os.Getenv("LOG_LEVEL"))

Functions

func GenerateCookie added in v0.0.22

func GenerateCookie() (*http.Cookie, error)

func GetCorsDisablingHandler added in v0.0.21

func GetCorsDisablingHandler(next http.Handler) http.Handler

GetCorsDisablingHandler This is necessary to allow cross-origin requests from the Ocelot-Cloud GUI to the Hub. or when testing frontend and backend components separately. The "Origin" header is managed and checked with custom logic to prevent CSRF attacks. TODO Rename to ApplyCorsDisable

func GetErrMsg

func GetErrMsg(actualStatusCode int, respBodyMsg string) string

func GetTimeIn30Days added in v0.0.22

func GetTimeIn30Days() time.Time

func Hash added in v0.0.23

func Hash(clearText string) (string, error)

func SaltAndHash added in v0.0.23

func SaltAndHash(clearText string) (string, error)

func SendJsonResponse

func SendJsonResponse(w http.ResponseWriter, data interface{})

func SetCookieHeaders added in v0.0.35

func SetCookieHeaders(req *http.Request, c *ComponentClient)

func UnpackResponse added in v0.0.32

func UnpackResponse[T any](object interface{}) (*T, error)

func UnzipToTempDir added in v0.0.42

func UnzipToTempDir(zipBytes []byte) (string, error)

TODO To be tested UnzipToTempDir unzips the given zip bytes to a temporary directory and returns the path to the directory.

func ZipDirectoryToBytes added in v0.0.30

func ZipDirectoryToBytes(dirPath string) ([]byte, error)

Types

type ChangePasswordForm

type ChangePasswordForm struct {
	OldPassword string `json:"old_password"`
	NewPassword string `json:"new_password"`
}

type ComponentClient

type ComponentClient struct {
	User            string
	Password        string
	NewPassword     string
	Cookie          *http.Cookie
	SetCookieHeader bool
	RootUrl         string
	Origin          string
}

func (*ComponentClient) DoRequest

func (c *ComponentClient) DoRequest(path string, payload interface{}, expectedMessage string) (interface{}, error)

func (*ComponentClient) DoRequestWithFullResponse

func (c *ComponentClient) DoRequestWithFullResponse(path string, payload interface{}, expectedMessage string) (*http.Response, error)

type SingleInteger added in v0.0.33

type SingleInteger struct {
	Value int `json:"value"`
}

type SingleString

type SingleString struct {
	Value string `json:"value"`
}

Jump to

Keyboard shortcuts

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