api

package
v0.0.0-...-7578c0e Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetUser

func GetUser(ctx context.Context, log *logger.Logger) string

GetUser returns a username from a given context.

func WithUser

func WithUser(ctx context.Context, username string) context.Context

WithUser returns a copy of a given context that contains a given username.

Types

type ErrorPayload

type ErrorPayload struct {
	Errors []ErrorPayloadItem `json:"errors"`
}

ErrorPayload represents a uniform format for all error API responses.

func NewErrAPIPayloadFromError

func NewErrAPIPayloadFromError(err error, code, detail string) ErrorPayload

func NewErrAPIPayloadFromMessage

func NewErrAPIPayloadFromMessage(code, title, detail string) ErrorPayload

type ErrorPayloadItem

type ErrorPayloadItem struct {
	Code   string `json:"code"`
	Title  string `json:"title"`
	Detail string `json:"detail"`
}

ErrorPayloadItem represents a uniform format for a single error used in API responses.

type ExecuteInput

type ExecuteInput struct {
	Command     string `json:"command"`
	Script      string `json:"script"`
	Interpreter string `json:"interpreter"`
	Cwd         string `json:"cwd"`
	IsSudo      bool   `json:"is_sudo"`
	TimeoutSec  int    `json:"timeout_sec"`
	ClientID    string
	IsScript    bool
}
type Links interface{}

type Meta

type Meta struct {
	Count int `json:"count"`
}

func NewMeta

func NewMeta(count int) *Meta

type SuccessPayload

type SuccessPayload struct {
	Data  interface{} `json:"data"`
	Meta  *Meta       `json:"meta,omitempty"`
	Links Links       `json:"links,omitempty"`
}

SuccessPayload represents a uniform format for all successful API responses.

func NewSuccessPayload

func NewSuccessPayload(data interface{}) SuccessPayload

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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