utils

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2025 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Version = "0.0.1"

	ApiBase = "/api/v1"
)

Functions

func GetAccessToken

func GetAccessToken() string

func GetApiBase

func GetApiBase() string

func GetPortFromAddr

func GetPortFromAddr(addr string) (string, error)

func GetRandomStr

func GetRandomStr(e int) string

func IsAPIError

func IsAPIError(err error) bool

func IsAuthError

func IsAuthError(err error) bool

func IsNetworkError

func IsNetworkError(err error) bool

func NewAPIError

func NewAPIError(statusCode int, body []byte) error

func NewAuthError

func NewAuthError() error

func NewInternalError

func NewInternalError(err error) error

func NewNetworkError

func NewNetworkError(err error) error

func SetAccessToken

func SetAccessToken(token string)

func SetHost

func SetHost(host string)

Types

type ErrMsg

type ErrMsg struct {
	Message string `json:"message"`
}

type Option

type Option func(client *PanelClient)

func WithHeaders

func WithHeaders(headers map[string]string) Option

func WithPayload

func WithPayload(payload interface{}) Option

func WithQuery

func WithQuery(query map[string]interface{}) Option

type PanelClient

type PanelClient struct {
	Url      string
	Method   string
	Payload  interface{}
	Headers  map[string]string
	Response *http.Response

	Query map[string]string
	// contains filtered or unexported fields
}

func NewPanelClient

func NewPanelClient(method, urlPath string, opts ...Option) *PanelClient

func (*PanelClient) Do

func (p *PanelClient) Do() (*PanelClient, error)

func (*PanelClient) GetRespBody

func (p *PanelClient) GetRespBody() ([]byte, error)

func (*PanelClient) IsFail

func (p *PanelClient) IsFail() bool

func (*PanelClient) IsSuccess

func (p *PanelClient) IsSuccess() bool

func (*PanelClient) ParseJSON

func (p *PanelClient) ParseJSON(v interface{}) error

func (*PanelClient) Request

func (p *PanelClient) Request(object any) (*mcp.CallToolResult, error)

func (*PanelClient) SetHeaders

func (p *PanelClient) SetHeaders(headers map[string]string) *PanelClient

type PanelError

type PanelError struct {
	Code    int
	Message string
	Details string
}

func NewPanelError

func NewPanelError(code int, message, details string) *PanelError

func (*PanelError) Error

func (e *PanelError) Error() string

Jump to

Keyboard shortcuts

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