36 lines
848 B
Go
36 lines
848 B
Go
// Package adapters are the backend to that connects the marka server to a storage
|
|
package adapters
|
|
|
|
import "time"
|
|
|
|
type FileAdapter interface {
|
|
Read(path string) (FsResponse, error)
|
|
Write(path string, content []byte) error
|
|
}
|
|
|
|
type FsFile struct {
|
|
Name string `json:"name"`
|
|
Type string `json:"type"`
|
|
Content []byte `json:"content"`
|
|
ModTime time.Time `json:"modTime"`
|
|
}
|
|
|
|
type FsDirEntry struct {
|
|
Name string `json:"name"`
|
|
Type string `json:"type"`
|
|
IsDir bool `json:"isDir,omitempty"`
|
|
ModTime time.Time `json:"modTime"`
|
|
Content any `json:"content,omitempty"`
|
|
}
|
|
|
|
type FsDir struct {
|
|
Files []FsDirEntry `json:"files"`
|
|
Name string `json:"name"`
|
|
ModTime time.Time `json:"modTime"`
|
|
}
|
|
|
|
type FsResponse struct {
|
|
Dir *FsDir `json:"dir,omitempty"`
|
|
File *FsFile `json:"file,omitempty"`
|
|
}
|