mirror of
https://github.com/matrix-org/dendrite
synced 2024-12-14 07:12:53 +00:00
cmd/client-api-proxy: Add proxy for media API (#133)
This commit is contained in:
parent
721c2df484
commit
def49400bc
1 changed files with 14 additions and 1 deletions
|
@ -49,6 +49,7 @@ Arguments:
|
||||||
var (
|
var (
|
||||||
syncServerURL = flag.String("sync-api-server-url", "", "The base URL of the listening 'dendrite-sync-api-server' process. E.g. 'http://localhost:4200'")
|
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'")
|
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.")
|
bindAddress = flag.String("bind-address", ":8008", "The listening port for the proxy.")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -109,7 +110,13 @@ func main() {
|
||||||
|
|
||||||
if *clientAPIURL == "" {
|
if *clientAPIURL == "" {
|
||||||
flag.Usage()
|
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)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,8 +128,13 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
mediaProxy, err := makeProxy(*mediaAPIURL)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
http.Handle("/_matrix/client/r0/sync", syncProxy)
|
http.Handle("/_matrix/client/r0/sync", syncProxy)
|
||||||
|
http.Handle("/_matrix/media/v1/", mediaProxy)
|
||||||
http.Handle("/", clientProxy)
|
http.Handle("/", clientProxy)
|
||||||
|
|
||||||
srv := &http.Server{
|
srv := &http.Server{
|
||||||
|
@ -133,6 +145,7 @@ func main() {
|
||||||
|
|
||||||
fmt.Println("Proxying requests to:")
|
fmt.Println("Proxying requests to:")
|
||||||
fmt.Println(" /_matrix/client/r0/sync => ", *syncServerURL+"/api/_matrix/client/r0/sync")
|
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(" /* => ", *clientAPIURL+"/api/*")
|
||||||
fmt.Println("Listening on ", *bindAddress)
|
fmt.Println("Listening on ", *bindAddress)
|
||||||
srv.ListenAndServe()
|
srv.ListenAndServe()
|
||||||
|
|
Loading…
Reference in a new issue