# The PrefixDir function

The `iris.PrefixDir` function wraps an existing "fs" file system and returns a new one which open files by prepending the path with the given "prefix".

```go
func PrefixDir(prefix string, fs http.FileSystem) http.FileSystem
```

It is extremely useful when you use a `go-bindata` file to embed both view templates and public static files. With `PrefixDir` you can select which directory to use to serve static files and which to render views.

## Example

```
│   main.go
|   bindata.go
└───data/
└──────views/
│         ...your templates
└──────public/
│         ...your public assets
```

Let's build the `bindata.go` file which will contain the embedded `./data` directory:

```sh
$ go get -u github.com/go-bindata/go-bindata/...
$ go-bindata -fs ./data/...
```

Use the `./data/views` for templates and `./data/public` for file server:

```go
templatesFS := iris.PrefixDir("./data/views", AssetFile())
app.RegisterView(iris.HTML(templatesFS, ".html"))

publicFS := iris.PrefixDir("./data/public", AssetFile())
app.HandleDir("/", publicFS)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://iris-go.gitbook.io/iris/file-server/prefixdir-function.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
