Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add yada functionality to serve a local system directory or file #111

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

luciodale
Copy link
Contributor

@luciodale luciodale commented Oct 10, 2019

Usage examples:

From your config.edn:

Serve directory:

...
:ig.system/base
{[:my.project/foo :edge.yada.ig/external-directories]
 {:path "/home/user/target/folder/"
  :options {:custom-suffices [...]
            :index-files [...]
             ...}}
...

And in your edge.bidi.ig/vhost:

["/foo/" #ig/ref [:my.project/foo :edge.yada.ig/external-directories]]

Serve single file:

...
:ig.system/base
{[:my.project/bar :edge.yada.ig/external-files]
 {:path "/home/user/target/folder/file.txt"
  :options {:produces [...]
              ...}}
...

And in your edge.bidi.ig/vhost:

["/file" #ig/ref [:my.project/bar :edge.yada.ig/external-files]]

Copy link
Contributor

@SevereOverfl0w SevereOverfl0w left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add docs to doc/resources/doc/sources/built-in-libraries.adoc

@@ -26,6 +26,16 @@
id
(assoc :id id)))

(defmethod ig/init-key ::external-directories
[_ {:keys [path options]}]
(yada.resources.file-resource/new-directory-resource
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to require this namespace before using it. See requiring-resolve below.

@@ -26,6 +26,16 @@
id
(assoc :id id)))

(defmethod ig/init-key ::external-directories
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe directory-resource is better? Then it can rely on the existing known name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't resource not ideal because the directory won't be on the classpath?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resource would refer to web resource in this context, same as in yada

(yada.resources.file-resource/new-directory-resource
(io/file path) (or options {})))

(defmethod ig/init-key ::external-files
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file-resource is perhaps better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants