0

I'm trying to use Grapevine to serve files from a directory on my hard drive. The url sent to request the file will end in a file extension, for example http://localhost:1234/contact.html.

I'm trying to catch the requests made with the Route

[RestRoute(HttpMethod = HttpMethod.GET, PathInfo = @".\w{2,4}\Z")]

yet it's not matching on anything. I've checked my regular expression syntax on a regular expression checker and it works.

Does Grapevine 4 still support regular expressions? Or is my path info wrong?

Thanks.

Sethmo

Sethmo011
  • 575
  • 7
  • 20
  • `@"\.\w{2,4}\Z"` – Wiktor Stribiżew Feb 27 '18 at 09:55
  • 1
    Your RegX does not match your example url... Use https://regex101.com or similar to check whether your RegX match your data. – Leo Feb 27 '18 at 09:58
  • 1
    Thanks @LeonardoSeccia for the website. I didn't realise I was looking for a pattern that would look like this http://localhost:1234/.html. Fixed it to look for the entire path [\/webapp\/]*[\/][\w]+\.\w{2,4}\Z – Sethmo011 Feb 27 '18 at 10:43
  • Apologies [\/webapp\/]*[\w]+.\w{2,4}\Z – Sethmo011 Feb 27 '18 at 10:49
  • After more wrangling [\/webapp\/]*[\.\w{2,4}]*\.\w{2,4}\Z. This matches all resources (webapp)*/. and (webapp)*/... So, "webapp/angular.min.js", i"ndex,html", "style.css"...etc. – Sethmo011 Feb 27 '18 at 11:17
  • An easier way to serve files would be to use the `PublicFolder` class here: https://github.com/sukona/Grapevine/blob/v4.1.1.0/src/Grapevine/Server/PublicFolder.cs – Scott Offen May 29 '18 at 17:17
  • 1
    `server.PublicFolders.Add(new PublicFolder("path/to/folder"));` – Scott Offen May 29 '18 at 17:19

0 Answers0