本文整理汇总了C#中Nancy.NancyContext.ToFullPath方法的典型用法代码示例。如果您正苦于以下问题:C# NancyContext.ToFullPath方法的具体用法?C# NancyContext.ToFullPath怎么用?C# NancyContext.ToFullPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nancy.NancyContext
的用法示例。
在下文中一共展示了NancyContext.ToFullPath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildAbsoluteUri
public Uri BuildAbsoluteUri(NancyContext context, string routeName, dynamic parameters = null)
{
var parameterDictionary = ToDictionary(parameters as object ?? new { });
var pathTemplate = GetRouteTemplateFromRouteName(routeName);
if (pathTemplate == null)
throw new UnknownRouteException(routeName, this.AllRoutes);
var realizedPath =
this.segmentExtractor.Extract(pathTemplate.Path)
.Aggregate("~", (accumulatedtPath, segment) => GetSegmentValue(segment, parameterDictionary, accumulatedtPath));
return uriFilter.Apply(new Uri(GetBaseUri(context), context.ToFullPath(realizedPath)), context);
}
示例2: After
private void After(NancyContext nancyContext)
{
if (nancyContext.Response != null)
{
var status = (int) nancyContext.Response.StatusCode;
var level = LogLevel.Error;
if (status >= 400 && status <= 600)
{
var req = nancyContext.Request;
if (status < 500)
level = LogLevel.Warn;
var logMessage = String.Format("Responding {0} for {1} to path {2}", status, req.Method,
nancyContext.ToFullPath(req.Path));
Logary.Logging.GetCurrentLogger()
.Log(level, logMessage, GetLogData(nancyContext), null, null, nancyContext.ToFullPath(req.Path));
}
nancyContext.Response.Headers.Add("Access-Control-Allow-Origin", "*");
nancyContext.Response.Headers.Add("Access-Control-Allow-Methods",
"GET, POST, PUT, DELETE, OPTIONS, PATCH");
nancyContext.Response.Headers.Add("Access-Control-Allow-Headers", "Content-Type");
}
}
示例3: Error
private Response Error(NancyContext nancyContext, Exception ex)
{
var req = nancyContext.Request;
var logMessage = string.Format("An error occurred handling {0} to {1}", nancyContext.Request.Method,
nancyContext.ToFullPath(req.Path));
Logary.Logging.GetCurrentLogger()
.Log(LogLevel.Error, logMessage, GetLogData(nancyContext), null, ex, nancyContext.ToFullPath(req.Path));
return nancyContext.Response;
}
示例4: RegisterFacebookOAuthClientPerRequest
private void RegisterFacebookOAuthClientPerRequest(TinyIoC.TinyIoCContainer container, NancyContext context)
{
var facebookOAuthClient =
new Facebook.FacebookOAuthClient(container.Resolve<Facebook.IFacebookApplication>())
{
RedirectUri = new Uri("http://localhost:45254" + context.ToFullPath("~/facebook/login/callback"))
};
container.Register(facebookOAuthClient);
}