首页 \ 问答 \ 将路由器操作委托给其他应用程序中的控制器(Delegate router actions to to controllers in other apps)

将路由器操作委托给其他应用程序中的控制器(Delegate router actions to to controllers in other apps)

我有一个与我的main应用程序有关的多个路线的凤凰伞项目,然后是一些与我的child应用程序相关的路线。

目前我绑定到两个端口(配置main_webchild_web的端口),然后链接到我的child应用中的路由,引用我的子端口与之关联的url。

我可以绑定到只有一个端口,并有下面的router.ex文件的行:

main_web / router.ex

scope "/" do
  pipe_through :browser

  get "/", MainWeb.PageController, :index
  resources "/user", MainWeb.UserController

  # Somehow delegating this to the ChildWeb app would be better
  scope "/child", ChildWeb do

    get "/", Page.Controller, :index
    resources "/other", OtherController
  end
end

child_web / router.ex

# if this is configured it would be everything after the /child url
scope "/", ChildWeb do
  get "/page1", Page1Controller, :index
end

我不确定完全是如何编写的,但是我觉得这个实现可能存在某个地方,如果有人可以参考我的例子或凤凰文档为上述,将不胜感激。


I have an phoenix umbrella project with a number of routes related to my main app, then a number of routes related to my child app.

Currently I am binding to two ports (the ports which main_web and child_web are configured for) I then link to routes inside my child app referencing the url which my child port is associated with.

Could I instead bind to just one port and have something down the lines of the following router.ex files:

main_web/router.ex

scope "/" do
  pipe_through :browser

  get "/", MainWeb.PageController, :index
  resources "/user", MainWeb.UserController

  # Somehow delegating this to the ChildWeb app would be better
  scope "/child", ChildWeb do

    get "/", Page.Controller, :index
    resources "/other", OtherController
  end
end

child_web/router.ex

# if this is configured it would be everything after the /child url
scope "/", ChildWeb do
  get "/page1", Page1Controller, :index
end

I'm not sure entirely how this would be written, but I feel that the implementation for this may exist somewhere, if someone could reference to me an example or phoenix documentation for the above that would be greatly appreciated.


原文:https://stackoverflow.com/questions/48406181
更新时间:2023-06-02 06:06

最满意答案

如何使用FTP上传文件

using System;
using System.IO;
using System.Net;
using System.Text;

namespace Examples.System.Net
{
    public class WebRequestGetExample
    {
        public static void Main ()
        {
            // Get the object used to communicate with the server.
            FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/test.htm");
            request.Method = WebRequestMethods.Ftp.UploadFile;

            // This example assumes the FTP site uses anonymous logon.
            request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com");

            // Copy the contents of the file to the request stream.
            StreamReader sourceStream = new StreamReader("testfile.txt");
            byte [] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
            sourceStream.Close();
            request.ContentLength = fileContents.Length;

            Stream requestStream = request.GetRequestStream();
            requestStream.Write(fileContents, 0, fileContents.Length);
            requestStream.Close();

            FtpWebResponse response = (FtpWebResponse)request.GetResponse();

            Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);

            response.Close();
        }
    }
}

How to: Upload Files with FTP:

using System;
using System.IO;
using System.Net;
using System.Text;

namespace Examples.System.Net
{
    public class WebRequestGetExample
    {
        public static void Main ()
        {
            // Get the object used to communicate with the server.
            FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/test.htm");
            request.Method = WebRequestMethods.Ftp.UploadFile;

            // This example assumes the FTP site uses anonymous logon.
            request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com");

            // Copy the contents of the file to the request stream.
            StreamReader sourceStream = new StreamReader("testfile.txt");
            byte [] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
            sourceStream.Close();
            request.ContentLength = fileContents.Length;

            Stream requestStream = request.GetRequestStream();
            requestStream.Write(fileContents, 0, fileContents.Length);
            requestStream.Close();

            FtpWebResponse response = (FtpWebResponse)request.GetResponse();

            Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);

            response.Close();
        }
    }
}

相关问答

更多
  • 选项3.当然简单,安全。 但是,生产质量POSIX兼容并行文件系统的性能足以让任何人真正关心使用它,通常会使用选项1与一些或多或少的相关机制相结合,以避免在例如多个客户端缓存同一文件时发生冲突。 俗话说,“计算机科学中只有两件事:缓存失效,命名事物和逐个错误”。 如果文件系统应该是POSIX兼容的,你需要学习POSIX fs语义,并查看fs如何在获得良好性能的同时支持这些(或者,它跳过POSIX语义的哪些部分,一个NFS)。 让错误更有趣的是,POSIX fs的语义可以追溯到1970年代,但是如何支持网络文 ...
  • 如何使用FTP上传文件 : using System; using System.IO; using System.Net; using System.Text; namespace Examples.System.Net { public class WebRequestGetExample { public static void Main () { // Get the object used to communicate wi ...
  • 您可以通过两种方式写入远程HDFS, 使用可用的WebHDFS api 。它支持在Hadoop集群外部运行的系统,以访问和操作HDFS内容。 它不需要客户端系统安装hadoop二进制文件。 将客户端系统配置为Hadoop edge node以与Hadoop集群/ HDFS进行交互。 请参考, https://hadoop.apache.org/docs/r1.2.1/webhdfs.html http://www.dummies.com/how-to/content/edge-nodes-in-hadoop ...
  • 从文档 (您确实检查了文档,对吗?),您需要FTP客户端上的appendFile()方法。 就像是 String text = "...." String remoteFileName = "..." FTPClient ftp = ... // Already connected try (ByteArrayInputStream local = new ByteArrayInputStream(text.toBytes("UTF-8"))) { ftp.appendFile(remoteFil ...
  • Mac OS(OS X)将/Volumes下的网络驱动程序与其他驱动程序一起加载。 因此,您的代码应如下所示: NSFileManager *filemgr; filemgr = [NSFileManager defaultManager]; if ([filemgr copyItemAtPath: stringFilePath toPath: @"/Volumes/NameOfFileShare/Path/To/Folder/FileName.png" error: NULL] == YES) NS ...
  • 它是从android访问php文件的代码 DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost("http://localhost/file.php?value="+output);//output is the variable you used in your program httpClient.execute(httpPost); //将上面的代码放在案例中 ...
  • 我认为你可以使用Java的sftp: https : //www.example-code.com/java/sftp.asp或https://kodehelp.com/java-program-for-uploading-file-to-sftp-server I think you can use sftp from Java: https://www.example-code.com/java/sftp.asp or https://kodehelp.com/java-program-for-uplo ...
  • 有一段时间有一个非常好的Blogpost用于记录到monolog和doctrine的mysql数据库。 我再也找不到了,所以我只想在这里添加必要的文件,你可以调整它。 整个逻辑在DatabaseHandler中完成,因此您可以从mysql插入更改为mongodb的处理。 如果有人知道原帖请注释,此代码不是我的。 BacktraceLoggerListener.php namespace UtilsBundle\EventListener; use Symfony\Component\HttpKernel\ ...
  • 我不知道你是否可以远程打开一个文件。 但即使可以,对您而言也许并不是一个好主意,因为您将通过ssh获取大文件(请记住Fabric仍在本地计算机上运行)。 为什么不远程压缩文件,然后获取压缩文件? 在mysqldump的情况下,它看起来像这样: run('mysqldump [options] | gzip > outputfile.sql.gz') get('outputfile.sql.gz') (更多关于mysqldump和gzip: 压缩mysqldump输出 ) I don't know if y ...
  • 您只需要使用不同的引用机制。 双引号允许命令和变量替换。 大括号将逐字记录其内容(禁止替代) set fh [open $tmpFileName w] puts $fh {set a [create_object]} puts $fh {$a proc1_inside_a} puts $fh {$a proc2_inside_a} close $fh 文档可用: Tcl的语法规则很少 - 比较规则4和规则6 Tcl教程 - 课程5和6适用 You just need to use a different ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)