sssp-1.1.1: HTTP proxy for S3.

Safe HaskellNone




data Task Source


Retrieve Text 
Listing [Text] 
Remove [Text] 
Write Text 


data Resource Source

Resources are either singular or plural in character. URLs ending ending in / or containing set wildcards specify plural resources; all other URLs indicate singular resources. A singular resource results in a redirect while a plural resource results in a newline-separated list of URLs (themselves singular in character).

data Ctx Source


data Order Source




data Wildcard Source


Hi Order 
Lo Order 

resource :: Request -> ResourceSource

Interpret a request URL as a resource, expanding wildcards as needed. By default, wildcards are expanded with @ as the meta-character (@hi, @lo.semver5) but the meta-character can be changed with a query parameter so we pass the whole request here.

The meta-character is in leading position in wildcard path components and escapes itself in leading position, in a simple way: leading runs are shortened by one character. Some examples of path components and their interpretation are helpful:

  hi      -> The string "hi".
  @hi     -> The hi.semver wildcard.
  @@hi    -> The string "@hi".
  @@@hi   -> The string "@@hi".
  ...and so on...

Sending meta=_ as a query parameter changes the meta-character to an underscore. The meta-character may be any single character; empty or overlong meta parameters are ignored.

component :: Char -> Parser (Either (Either Text Wildcard) SetWildcard)Source

Parse a single path component.

plain :: Char -> Parser TextSource

Parse a plain string, shrinking leading runs of the metacharacter by one.

wildcard :: Char -> Parser WildcardSource

Match a simple, singular wildcard.

setWildcard :: Char -> Parser SetWildcardSource

Match a wildcard set, ending with a count (if it is inclusive) or an optional count and a final tilde (if it is exclusive).

wildcards :: [(Text, Wildcard)]Source

Wildcards and their textual representations.

resolve :: Ctx -> Resource -> ResourceT IO (Attempt [Text])Source

Translate a resource in to a listing of objects. While intermediate S3 prefixes (directories) are traversed, the final match is always on keys for objects.

s3Pieces :: Text -> [Text]Source

Split a URL into components, placing the balance of slashes in a slash run to the left of the last slash. This is what all the Amazon APIs -- including the HTTP interface -- seem to expect, based on experiment. This function exists so that we can split a URL retrieved from S3, by way of list bucket, for example, into pieces for later escaping.

s3Encode :: Text -> BuilderSource

Encode an S3 path to a URL, splitting on slashes but preserving slash runs as appropriate.

order :: Order -> [Text] -> [Text]Source