本文整理汇总了C#中DreamContext.Relay方法的典型用法代码示例。如果您正苦于以下问题:C# DreamContext.Relay方法的具体用法?C# DreamContext.Relay怎么用?C# DreamContext.Relay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DreamContext
的用法示例。
在下文中一共展示了DreamContext.Relay方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProxyToService
public Yield ProxyToService(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
PermissionsBL.IsUserAllowed(DekiContext.Current.User, Permissions.ADMIN);
//Private feature requires api-key
var identifier = context.GetParam("id");
ServiceRepository.IServiceInfo serviceInfo = null;
if(identifier.StartsWith("=")) {
serviceInfo = DekiContext.Current.Instance.RunningServices[XUri.Decode(identifier.Substring(1))];
} else {
uint serviceId;
if(uint.TryParse(identifier, out serviceId)) {
serviceInfo = DekiContext.Current.Instance.RunningServices[serviceId];
} else {
throw new DreamBadRequestException(string.Format("Invalid id '{0}'", identifier));
}
}
if(serviceInfo == null) {
response.Return(DreamMessage.NotFound(string.Format(DekiResources.SERVICE_NOT_FOUND, identifier)));
yield break;
}
var proxyUri = serviceInfo.ServiceUri.At(context.GetSuffixes(UriPathFormat.Original).Skip(1).ToArray());
yield return context.Relay(Plug.New(proxyUri), request, response);
}
示例2: GetHttp
public Yield GetHttp(DreamContext context, DreamMessage request, Result<DreamMessage> response)
{
yield return context.Relay(_redirect.At(context.GetSuffixes(UriPathFormat.Original)), request, response);
}
示例3: GetImage
public Yield GetImage(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
string image = context.GetParam("name");
if(Path.GetExtension(image) != ".png") {
response.Return(DreamMessage.NotFound("image not found"));
} else {
yield return context.Relay(Storage.At(image), request, response);
}
}
示例4: GetImage
public Yield GetImage(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
yield return context.Relay(Storage.At(context.GetParam("name")), request, response);
}
示例5: GetFiles
public Yield GetFiles(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
if(_resourcesUri != null) {
yield return context.Relay(Plug.New(_resourcesUri).AtPath(string.Join("/", context.GetSuffixes(UriPathFormat.Original))), request, response);
} else {
response.Return(GetFile(context));
}
yield break;
}
示例6: GetErrorXsl
public Yield GetErrorXsl(DreamContext context, DreamMessage request, Result<DreamMessage> response)
{
string resource = context.GetParam("resource");
Plug plug = Plug.New(string.Format("resource://mindtouch.core/MindTouch.Dream.resources.host.{0}", resource)).With(DreamOutParam.TYPE, MimeType.FromFileExtension(resource).FullType);
yield return context.Relay(plug, request, response);
}
示例7: home
public Yield home(DreamContext context) {
yield return context.Relay(_fs.At("metl.html"), "GET:", null, null);
}
示例8: PostUnsubscribeEvents
public Yield PostUnsubscribeEvents(DreamContext context, DreamMessage request, Result<DreamMessage> response)
{
yield return context.Relay(_events.At("unsubscribe"), request, response);
}
示例9: FeatureGetAuthenticate
public Yield FeatureGetAuthenticate(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
string user = Authenticate(context, request);
string password;
HttpUtil.GetAuthentication(context.Uri.ToUri(), request.Headers, out user, out password);
yield return context.Relay(Self.At("users", XUri.Encode(user)).WithCredentials(user, password), request, response);
}