Skip to content

Commit

Permalink
improve docs (#2482)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomTriple authored Oct 15, 2023
1 parent e195aa4 commit 3a6525c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion zio-http/src/main/scala/zio/http/Middleware.scala
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,28 @@ object Middleware extends HandlerAspects {

/**
* Creates a middleware for serving static files from the directory `docRoot`
* at the path `path`.
* at the url path `path`.
*
* Example: `val serveDirectory = Middleware.serveDirectory(Path.empty /
* "assets", new File("/some/local/path"))`
*
* With this middleware in place, a request to
* `https://www.domain.com/assets/folder/file1.jpg` would serve the local file
* `/some/local/path/folder/file1.jpg`.
*/
def serveDirectory(path: Path, docRoot: File)(implicit trace: Trace): Middleware[Any] =
toMiddleware(path, StaticServe.fromDirectory(docRoot))

/**
* Creates a middleware for serving static files from resources at the path
* `path`.
*
* Example: `val serveResources = Middleware.serveResources(Path.empty /
* "assets")`
*
* With this middleware in place, a request to
* `https://www.domain.com/assets/folder/file1.jpg` would serve the file
* `src/main/resources/folder/file1.jpg`.
*/
def serveResources(path: Path)(implicit trace: Trace): Middleware[Any] =
toMiddleware(path, StaticServe.fromResource)
Expand Down

0 comments on commit 3a6525c

Please sign in to comment.