Skip to content
Snippets Groups Projects
Commit fe98ff4d authored by Travis Ralston's avatar Travis Ralston
Browse files

Add /_matrix/media/version for identifying the version of the repo

parent 1dee4074
No related branches found
No related tags found
No related merge requests found
package custom
import (
"net/http"
"github.com/turt2live/matrix-media-repo/api"
"github.com/turt2live/matrix-media-repo/common/rcontext"
"github.com/turt2live/matrix-media-repo/common/version"
)
func GetVersion(r *http.Request, rctx rcontext.RequestContext, user api.UserInfo) interface{} {
return &api.DoNotCacheResponse{
Payload: map[string]string{
"Version": version.Version,
"GitCommit": version.GitCommit,
},
}
}
......@@ -71,10 +71,14 @@ func Init() *sync.WaitGroup {
startImportHandler := handler{api.RepoAdminRoute(custom.StartImport), "start_import", counter, false}
appendToImportHandler := handler{api.RepoAdminRoute(custom.AppendToImport), "append_to_import", counter, false}
stopImportHandler := handler{api.RepoAdminRoute(custom.StopImport), "stop_import", counter, false}
versionHandler := handler{api.AccessTokenOptionalRoute(custom.GetVersion), "get_version", counter, false}
routes := make(map[string]route)
versions := []string{"r0", "v1", "unstable"} // r0 is typically clients and v1 is typically servers. v1 is deprecated.
// Things that don't need a version
routes["/_matrix/media/version"] = route{"GET", versionHandler}
for _, version := range versions {
// Standard routes we have to handle
routes["/_matrix/media/"+version+"/upload"] = route{"POST", uploadHandler}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment