Documentation ¶
Overview ¶
Package server implements the file storage service functionality and API.
Index ¶
Constants ¶
const ( HttpGET = "GET" // HTTP get method. HttpPOST = "POST" // HTTP post method. HttpPUT = "PUT" // HTTP put method. HttpDELETE = "DELETE" // HTTP delete method. HttpOPTIONS = "OPTIONS" // HTTP options method. )
const (
RootSymbol = "/"
)
Variables ¶
var ( FlagTrue = true FlagFalse = false )
Functions ¶
func StartServer ¶
func StartServer(cfg *Configuration) *http.Server
StartServer starts the file server.
func StopServer ¶ added in v0.0.8
StopServer gracefully stops the server.
Types ¶
type Configuration ¶
type Configuration struct { ServerPort int `json:"serverPort"` // Port number on which the server will be waiting for requests. RootDirectory string `json:"rootDirectory"` // Name of the root directory, where all content will be stored. UrlPrefix string `json:"urlPrefix"` // Prefix that will be prepended to all API endpoints. }
Configuration structure stores all configuration options available for the server. ServerPort defines the port number the file server will be listening for incoming API requests. RootDirectory defines the directory that is a parent for all other directories and files stored on server. All directory or file names used in API calls should be relative to root directory. UrlPrefix defines the prefix that will be prepended to all API endpoints.
func (*Configuration) DisplaySummary ¶
func (c *Configuration) DisplaySummary()
DisplaySummary prints current configuration setting to standard output.
type Directory ¶
type Directory struct { Name string `json:"name,omitempty" api:"Name of the directory without parent path."` Directories []*Directory `json:"directories,omitempty" api:"Child directories in this directory."` Files []*File `json:"files,omitempty" api:"Files contained in this directory."` }
Directory stores directory attributes like name and contained files and directories.
func (*Directory) AddDirectory ¶
AddDirectory adds new subdirectory with specified name.
type DirectoryDto ¶
type DirectoryDto struct {
Data *Directory `json:"data" api:"Directory details."`
}
DTO for directory.
type DirectoryListDto ¶ added in v0.0.8
type DirectoryListDto struct {
Data []string `json:"data" api:"List of directories."`
}
DTO for directory list.
type ErrorDto ¶
type ErrorDto struct { Status string `json:"status" api:"The HTTP status code applicable to this problem."` Code string `json:"code" api:"An application-specific error code."` Title string `` /* 136-byte string literal not displayed */ Detail string `json:"detail" api:"A human-readable explanation specific to this occurrence of the problem."` }
type ErrorsDto ¶
type ErrorsDto struct {
Errors []ErrorDto `json:"errors" api:"List of encountered problems"`
}
type File ¶
type File struct { Name *string `json:"name,omitempty" api:"File name without parent path."` Size *int64 `json:"size,omitempty" api:"File size in bytes."` Checksum *string `json:"checksum,omitempty" api:"File checksum (SHA256)."` Exists *bool `json:"exists,omitempty" api:"Flag indicating if file exists."` }
File stores single file attributes like name and size.
type FileDto ¶
type FileDto struct {
Data *File `json:"data,omitempty" api:"File details."`
}
DTO object for file.
type Handler ¶
type Handler func(w http.ResponseWriter, req *http.Request)
Type for defining request handlers.
type RouteHandler ¶
type RouteHandler func(cfg *Configuration, w http.ResponseWriter, req *http.Request)
Type for defining route handlers.