Documentation ¶
Index ¶
Constants ¶
const CompressionDeflate = "deflate"
CompressionDeflate compressionType deflate
Variables ¶
This section is empty.
Functions ¶
func GetResourceContent ¶
GetResourceContent receives a file path and return the content in a []byte
func StartServer ¶
func StartServer(config Configuration) error
StartServer starts the HTTP Server and loads the resources
Types ¶
type Configuration ¶
Configuration allow to setup the server configurations
type InMemoryResource ¶
type InMemoryResource struct { Name string Type ResourceType CompressionType Compression Size int InitialSize int Content []byte }
InMemoryResource hold the resouce that can be served by the server
func NewInMemoryResource ¶
func NewInMemoryResource(name string, content []byte) (InMemoryResource, error)
NewInMemoryResource method will initialize a new InMemoryResource object and return it
func (*InMemoryResource) String ¶
func (resource *InMemoryResource) String() string
String method will genereate a string representation of the InMemoryResource object
type ResourceCache ¶
type ResourceCache struct {
// contains filtered or unexported fields
}
ResourceCache hold all the resources to be served
func (ResourceCache) Exists ¶
func (cache ResourceCache) Exists(name string) bool
Exists return true if the resource exists on cache and false otherwise
func (ResourceCache) GetResource ¶
func (cache ResourceCache) GetResource(name string) (InMemoryResource, error)
GetResource return the in memory resource content
func (ResourceCache) Size ¶
func (cache ResourceCache) Size() int
Size returns the number of resources in memory
type ResourceFile ¶
ResourceFile holds the relative and absolute path of the file
func SearchFiles ¶
func SearchFiles(rootDir string) ([]ResourceFile, error)
SearchFiles lookup for all the files on the rootDir and sub directories
type ResourceType ¶
type ResourceType = string
ResourceType specifies the content type of the resource