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

Support For Multiple Public Folders #79

Closed
14 tasks done
scottoffen opened this issue Jul 22, 2016 · 4 comments
Closed
14 tasks done

Support For Multiple Public Folders #79

scottoffen opened this issue Jul 22, 2016 · 4 comments
Assignees
Milestone

Comments

@scottoffen
Copy link
Owner

scottoffen commented Jul 22, 2016

Current behavior is that implementations of IServerSettings have a public property that is a single instance of PublicFolder, that automatically creates the expected folder if it does not exist.

Desired behavior is that implementations of IServerSettings have a public property that is a collection of PublicFolder instances, and that the IServerSettings.PublicFolder property is used to manipulate the first item in this collection.

Implementation Details

IServerSettings.PublicFolders Collection

  • PublicFolders collection is a property of IServerSettings
  • PublicFolders collection is empty by default
  • New PublicFolder instances can be added to the collection at any time
  • Existing PublicFolder instances can be removed from the collection at any time
  • Routing checks the collection for the existence of a file before passing a request to routing table

IServerSettings.PublicFolder Object

  • PublicFolder property gets/sets the first item in the PublicFolders collection
  • PublicFolder public accessor creates the default PublicFolder and puts it in the collection upon first access when the PublicFolders collection is empty

PublicFolder Class

  • Default folder name for is \public in the current directory
  • Default index file name is index.html
  • Each instance has its own Prefix property
  • Each instance caches paths to all files, folders and subfolders contained in it
  • The cache key is the expected PathInfo for the file and the value is the fully qualified path to the file on the file system
  • Each instance has a public property bool:IncludeSubfolders that defaults to True This is a property of FileSystemWatcher.
  • Each instance has a FileSystemWatcher property that updates the cache when files or folders are added, removed or renamed
@mattiasclaesson
Copy link

Hi,

It would be good to be able to opt out from using the public folder functionlity.

One issue with it is the following:
When running as a non admnistrator account either as a normal user or service, its not permitted to create folders like the default "public".

Maybe there is a way to disable it allready in the current release?

@scottoffen
Copy link
Owner Author

In the current release I'm afraid there is no way to opt out.

However, I'm in the middle of working on this feature right now, and this is already (albeit somewhat unintentionally) in there. Check it out in the public-folder branch if you'd like.

The PublicFolder property is now just syntactic sugar to get to PublicFolders.First(). If there aren't any PublicFolder objects in the collection when you try to access PublicFolder, then the default is created for you and pushed into the collection. When the PublicFolder object is created it will attempt to create the folder if it doesn't already exist. The PublicFolders collection is empty by default, and all the core code operates on the collection rather than any individual object.

In short: Don't ever reference RestServer.PublicFolder and no folder will attempt to be created. Feel free to iterate over RestServer.PublicFolders as this will not cause any new instances of PublicFolder to be created.

There are some unit tests around this behavior, too, to make sure I don't accidentally change the behavior.

I'm glad someone actually wants this rather than me just thinking it would be a nice-to-have...!

@scottoffen
Copy link
Owner Author

@mattiasclaesson Out of curiosity, are you using Grapevine in your Trionic project?

@mattiasclaesson
Copy link

@scottoffen No its for another project that needed a REST interface.

Working with windows services and its limited service accounts it quite painfull.
Currently fighting with verifying a certificate chain on a client cetificate.

scottoffen pushed a commit that referenced this issue Jan 12, 2017
Adds support to RestServer for multiple public folders, and rearranges
logic between RestServer and Router for actual routing. Adds additional
unit tests for Grapevine.Serve namespace.

See issue #79 for more detail.
scottoffen pushed a commit that referenced this issue Jan 13, 2017
Adds support to RestServer for multiple public folders, and rearranges
logic between RestServer and Router for actual routing. Adds additional
unit tests for Grapevine.Serve namespace.

See issue #79 for more detail.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants