Open Crisfole opened 9 years ago
You're probably right, but is this from you running into the issue when using linker or from reading the code?
My co-worker using the linker and me reading the code :)
Do you have quick repro? If not I'm sure I can whip one up.
Christian Horsdal
Horsdal Consult ApS Sandøgade 4 8200 Århus N
www.horsdal-consult.dk +45 28 89 65 02
On Mon, Mar 16, 2015 at 8:02 PM, Christopher Pfohl <notifications@github.com
wrote:
My co-worker using the linker and me reading the code :)
— Reply to this email directly or view it on GitHub https://github.com/horsdal/Nancy.Linker/issues/4#issuecomment-81874147.
Probably could, but not now, not sure how to fake the root path provider. Would probably be a lot faster for you. Here's what I came up with until I got stuck:
public class Boot : DefaultNancyBootstrapper {
protected override IRootPathProvider RootPathProvider {
get { return new MyRootPathProvider(); }
}
}
public class MyRootPathProvider : IRootPathProvider {
public string GetRootPath() {
return "/should";
}
}
public class Module : NancyModule {
public Module(IResourceLinker linker) {
Get["absolute", "/abs/{whatever}"] = p => linker.BuildAbsoluteUri(Context, "absolute", new { whatever = p.whatever });
Get["relative", "/rel/{whatever}"] = p => linker.BuildRelativeUri(Context, "relative", new { whatever = p.whatever });
}
}
I'd expect the above to return /should/abs/{segment} and /should/rel/{segment}. But in reality it ignores the should
part.
The IRootPathProvider
does now effect the URLs of your endpoints. It tells Nancy where your application is located on disk. From the documentation:
All paths that are used in Nancy are relative to something that is known as the root path. This is the path that tells Nancy where its resources are stored on the file system. The root path is provided to Nancy through the IRootPathProvider interface, which defines a single method, GetRootPath.
So I'm ending up not understanding the issue. What am I missing?
I have the same issue. The strange part is that it works, if i copy/past the Linker code into my project. But if I use the NuGet reference, it does not work. Ill try to make a simple repro :)
A repro would be :cool: I do want to figure this one out.
Done: https://github.com/IngvarKofoed/Nancy.Linker.RootPath.Issue4.Repro
The strange part is that if I compile Nancy.Linker my self (after chaning LangVersion from experimental to 6) using using 2015 RC, then there is no issue. So it might just be a bad compilation?
Could be the build. Maybe LangVersion=Experimental
was too optimistic.
Thanks for the repro I'll see if I can find the bug within the next couple of days.
Cool!! Just made a small pull request that converts the solution and projects to VS2015 RC to spare you 5 minutes of work :)
So now three months later my report is clearly a misphrasing of the actual issue: when I used the term "root path" I shouldn't have conflated it with filesystem Root Path.
The issue is when the app is hosted from some other base than /
. I assume you figured out what I meant...
Oh, no. Is that the cause my misunderstanding you. Damnit. Anyhow, hope we get resolved now.
No. You currently understood me :). I just demonstrated a terrible understanding of Nancy.
Confused again. @Crisfole is your issue resolved or not?
Not yet. Although I'm not sure how to demo it. Deploy a site using linker to an iis site that is not hosted from /
, but is hosted from /demo
. The demo
portion of the URL will be missing
Got it ... I think :smile_cat:
Give me a few minutes and I'll get on jabbr. Ping me if you need more info.
@IngvarKofoed I assume the output of a GET
to that http://localhost:8812/
should be
{
"serverTime":"2015-06-30T20:42:49",
"apiName":"xxxx",
"version":"v0.2",
"hone":"http://localhost:8812/"
}
That's what I got after building a new package and upgrading your repro project to that. -Seems like the fix was your language version thing.
@IngvarKofoed I put a 0.3.0-Pre1 one package on NuGet (https://www.nuget.org/packages/Nancy.Linker/0.3.0-Pre1). Could you check if that solves your issue? Thanks!
Verified! Thanks! :)
Doesn't look like the
linker
takes the root path into consideration.You might want to think about prepending the results of the linker with the application root path.