From def49400bc2bccdaa190d93f2939d747bafeb7be Mon Sep 17 00:00:00 2001 From: Robert Swain Date: Mon, 5 Jun 2017 15:55:04 +0200 Subject: [PATCH] cmd/client-api-proxy: Add proxy for media API (#133) --- .../dendrite/cmd/client-api-proxy/main.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/github.com/matrix-org/dendrite/cmd/client-api-proxy/main.go b/src/github.com/matrix-org/dendrite/cmd/client-api-proxy/main.go index fb8751ca..a9b35931 100644 --- a/src/github.com/matrix-org/dendrite/cmd/client-api-proxy/main.go +++ b/src/github.com/matrix-org/dendrite/cmd/client-api-proxy/main.go @@ -49,6 +49,7 @@ Arguments: var ( syncServerURL = flag.String("sync-api-server-url", "", "The base URL of the listening 'dendrite-sync-api-server' process. E.g. 'http://localhost:4200'") clientAPIURL = flag.String("client-api-server-url", "", "The base URL of the listening 'dendrite-client-api-server' process. E.g. 'http://localhost:4321'") + mediaAPIURL = flag.String("media-api-server-url", "", "The base URL of the listening 'dendrite-media-api-server' process. E.g. 'http://localhost:7779'") bindAddress = flag.String("bind-address", ":8008", "The listening port for the proxy.") ) @@ -109,7 +110,13 @@ func main() { if *clientAPIURL == "" { flag.Usage() - fmt.Fprintln(os.Stderr, "no --client-api-url specified.") + fmt.Fprintln(os.Stderr, "no --client-api-server-url specified.") + os.Exit(1) + } + + if *mediaAPIURL == "" { + flag.Usage() + fmt.Fprintln(os.Stderr, "no --media-api-server-url specified.") os.Exit(1) } @@ -121,8 +128,13 @@ func main() { if err != nil { panic(err) } + mediaProxy, err := makeProxy(*mediaAPIURL) + if err != nil { + panic(err) + } http.Handle("/_matrix/client/r0/sync", syncProxy) + http.Handle("/_matrix/media/v1/", mediaProxy) http.Handle("/", clientProxy) srv := &http.Server{ @@ -133,6 +145,7 @@ func main() { fmt.Println("Proxying requests to:") fmt.Println(" /_matrix/client/r0/sync => ", *syncServerURL+"/api/_matrix/client/r0/sync") + fmt.Println(" /_matrix/media/v1 => ", *mediaAPIURL+"/api/_matrix/media/v1") fmt.Println(" /* => ", *clientAPIURL+"/api/*") fmt.Println("Listening on ", *bindAddress) srv.ListenAndServe()