mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-26 05:31:32 +00:00
cmd/client-api-proxy: Add proxy for media API (#133)
This commit is contained in:
parent
721c2df484
commit
def49400bc
@ -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 New Issue
Block a user