Documentation ¶
Index ¶
Constants ¶
View Source
const (
// Per default items up to 20 Mibibytes in size will be cached
DEFAULT_MAX_CACHEABLE_SIZE = 20 * (1 << (10 * 2))
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct { // Time for which a answer is held im memory. A TTL <= 0 // makes the Cache pass all requests directly to the handler. TTL time.Duration // Handler, whose responses are supposed to be cached Handler http.Handler // Maximum number of bytes, with which an response is eligible // for caching (default: 20MiB) MaxCacheableSize int64 // contains filtered or unexported fields }
Cache is a `net/http.Handler`, which uses `net/http/httptest.ResponseRecorder` to record and recall the responses of the wrapped handler from memory if the same URL is requested again. The `net/http.Request.URL.Path` is used as the caching key.
type GridDir ¶
type GridDir struct { GridFS *mgo.GridFS // If true, the leading slash will be stripped from requests StripSlash bool }
GridDir implements net/http.FileSystem to serve contents directly from MongoDB's GridFS.
To serve all files from a database containing a GridFS called `fs` via http:
session, err := mgo.Dial("mongodb://localhost/database") if err != nil { log.Fatalf("Could not connect to mongodb: %s", err) } gfs := session.DB("").GridFS("fs") http.Handle("/", http.FileServer(sabercat.GridDir{gfs})
Directory listing has not been implemented.
Click to show internal directories.
Click to hide internal directories.