Skip to content

axum-extra SpaRouter support include_dir! #1698

@Sherlock-Holo

Description

@Sherlock-Holo
  • I have looked for existing issues (including closed) about this

Feature Request

Motivation

when using SpaRouter, it needs a real dir in the fs, however, sometimes the resources may include in the binary by something like include_dir!.

If SpaRouter allows using a virtual dir to access the resources, it will increase the practical

Proposal

maybe SpaRouter can provide a trait like

trait VirtualDir {
    type VirtualFile: AsyncRead + AsyncWrite + AsyncSeek + Unpin + Send + 'static;
    type VirtualFilenameStream: Stream<Item=io::Result<PathBuf>> + Unpin + Send + 'static;


    async fn open_file(&self, name: &str) -> io::Result<Self::VirtualFile>;

    async fn list_files(&self, dir: &str) -> io::Result<Self::VirtualFilenameStream>;
}

to allow user pass a virtual dir to the SpaRouter

Alternatives

user can also try to write the file data to a tmp dir and let SpaRouter access them, but I don't think this way is a good idea

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions