server

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrInvalidMethod    = "INVALID_METHOD"
	ErrInvalidJSON      = "INVALID_JSON"
	ErrUnknownOperation = "UNKNOWN_OPERATION"
	ErrMissingPath      = "MISSING_PATH"
	ErrInvalidPath      = "INVALID_PATH"
	ErrFileNotFound     = "FILE_NOT_FOUND"
	ErrOperationFailed  = "OPERATION_FAILED"
)
View Source
const (
	PREFIX_DRIVE string = "/drive/"
)

Variables

This section is empty.

Functions

func CreateServer

func CreateServer(config *Config) (*http.Server, error)

CreateServer creates an HTTP server with the specified configuration

func GetFileIcon

func GetFileIcon(filename string, fileType string) string

func GetFileType

func GetFileType(filename string, root string) string

func GetLocalIP

func GetLocalIP() string

GetLocalIP returns the non-loopback local IPv4 address

func PrintAccessInfo

func PrintAccessInfo(config *Config)

PrintAccessInfo prints server access information

Types

type APIRequest

type APIRequest struct {
	File   bool                   `json:"file"`
	Type   string                 `json:"type"`
	Path   string                 `json:"path"`
	Src    string                 `json:"src,omitempty"`
	Dst    string                 `json:"dst,omitempty"`
	Option map[string]interface{} `json:"option,omitempty"`
}

type APIResponse

type APIResponse struct {
	Success   bool        `json:"success"`
	Message   string      `json:"message"`
	ErrorCode string      `json:"error_code,omitempty"`
	Data      interface{} `json:"data,omitempty"`
}

type Config

type Config struct {
	Port    int
	RootDir string
	LogFlag bool
}

Config holds the configuration for the server

type DirectoryContent

type DirectoryContent struct {
	Path        string
	Files       []FileInfo
	CurrentPath string
}

type FileInfo

type FileInfo struct {
	Name    string
	Size    int64
	Mode    os.FileMode
	ModTime time.Time
	IsDir   bool
	Type    string
}

type HealthStatus

type HealthStatus struct {
	Status        string    `json:"status"`
	Uptime        string    `json:"uptime"`
	MemoryUse     float64   `json:"memory_use"`
	CPUUse        float64   `json:"cpu_use"`
	DiskUse       float64   `json:"disk_use"`
	NetworkIn     uint64    `json:"network_in"`
	NetworkOut    uint64    `json:"network_out"`
	DiskStatus    string    `json:"disk_status"`
	NetworkStatus string    `json:"network_status"`
	StartTime     time.Time `json:"start_time"`
}

type SearchCondition

type SearchCondition struct {
	Term    string
	IsRegex bool
	IsNot   bool
}

type SearchQuery

type SearchQuery struct {
	Conditions []SearchCondition
	IsOr       bool
}

type SearchResult

type SearchResult struct {
	Name    string    `json:"name"`
	Path    string    `json:"path"`
	Type    string    `json:"type"`
	Size    int64     `json:"size"`
	ModTime time.Time `json:"modTime"`
}

type SearchResultPage

type SearchResultPage struct {
	Query   string
	Results []SearchResult
}

Jump to

Keyboard shortcuts

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