将路由器操作委托给其他应用程序中的控制器(Delegate router actions to to controllers in other apps)
我有一个与我的
main
应用程序有关的多个路线的凤凰伞项目,然后是一些与我的child
应用程序相关的路线。目前我绑定到两个端口(配置
main_web
和child_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 mychild
app.Currently I am binding to two ports (the ports which
main_web
andchild_web
are configured for) I then link to routes inside mychild
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
最满意答案
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年代,但是如何支持网络文 ...
-
我如何写入远程文件?(How can I write to a remote file?)[2022-12-25]
如何使用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 ...
-
如何使用Apache Commons Net写入远程文件?(How can I write to a remote file using Apache Commons Net?)[2022-04-14]
从文档 (您确实检查了文档,对吗?),您需要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 ...
-
如何写入文件?(How to write in file?)[2022-06-18]
您只需要使用不同的引用机制。 双引号允许命令和变量替换。 大括号将逐字记录其内容(禁止替代) 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 ...