fix code smells

This commit is contained in:
A.Unger
2021-11-15 10:03:42 +01:00
parent 242b3e9eb9
commit a22342ea28
3 changed files with 32 additions and 28 deletions
+27 -24
View File
@@ -256,6 +256,10 @@ func DefaultConfig() *Config {
} }
func defaultPolicies() []Policy { func defaultPolicies() []Policy {
const idpBackend = "http://localhost:9130"
const revaBackend = "http://localhost:9140"
const namedDemoBackend = "https://demo.owncloud.com"
return []Policy{ return []Policy{
{ {
Name: "ocis", Name: "ocis",
@@ -266,19 +270,19 @@ func defaultPolicies() []Policy {
}, },
{ {
Endpoint: "/.well-known/", Endpoint: "/.well-known/",
Backend: "http://localhost:9130", Backend: idpBackend,
}, },
{ {
Endpoint: "/konnect/", Endpoint: "/konnect/",
Backend: "http://localhost:9130", Backend: idpBackend,
}, },
{ {
Endpoint: "/signin/", Endpoint: "/signin/",
Backend: "http://localhost:9130", Backend: idpBackend,
}, },
{ {
Endpoint: "/archiver", Endpoint: "/archiver",
Backend: "http://localhost:9140", Backend: revaBackend,
}, },
{ {
Type: RegexRoute, Type: RegexRoute,
@@ -287,7 +291,7 @@ func defaultPolicies() []Policy {
}, },
{ {
Endpoint: "/ocs/", Endpoint: "/ocs/",
Backend: "http://localhost:9140", Backend: revaBackend,
}, },
{ {
Type: QueryRoute, Type: QueryRoute,
@@ -296,31 +300,31 @@ func defaultPolicies() []Policy {
}, },
{ {
Endpoint: "/remote.php/", Endpoint: "/remote.php/",
Backend: "http://localhost:9140", Backend: revaBackend,
}, },
{ {
Endpoint: "/dav/", Endpoint: "/dav/",
Backend: "http://localhost:9140", Backend: revaBackend,
}, },
{ {
Endpoint: "/webdav/", Endpoint: "/webdav/",
Backend: "http://localhost:9140", Backend: revaBackend,
}, },
{ {
Endpoint: "/status.php", Endpoint: "/status.php",
Backend: "http://localhost:9140", Backend: revaBackend,
}, },
{ {
Endpoint: "/index.php/", Endpoint: "/index.php/",
Backend: "http://localhost:9140", Backend: revaBackend,
}, },
{ {
Endpoint: "/data", Endpoint: "/data",
Backend: "http://localhost:9140", Backend: revaBackend,
}, },
{ {
Endpoint: "/app/", Endpoint: "/app/",
Backend: "http://localhost:9140", Backend: revaBackend,
}, },
{ {
Endpoint: "/graph/", Endpoint: "/graph/",
@@ -335,7 +339,6 @@ func defaultPolicies() []Policy {
Endpoint: "/api/v0/accounts", Endpoint: "/api/v0/accounts",
Backend: "http://localhost:9181", Backend: "http://localhost:9181",
}, },
// TODO the lookup needs a better mechanism
{ {
Endpoint: "/accounts.js", Endpoint: "/accounts.js",
Backend: "http://localhost:9181", Backend: "http://localhost:9181",
@@ -359,53 +362,53 @@ func defaultPolicies() []Policy {
}, },
{ {
Endpoint: "/.well-known/", Endpoint: "/.well-known/",
Backend: "http://localhost:9130", Backend: idpBackend,
}, },
{ {
Endpoint: "/konnect/", Endpoint: "/konnect/",
Backend: "http://localhost:9130", Backend: idpBackend,
}, },
{ {
Endpoint: "/signin/", Endpoint: "/signin/",
Backend: "http://localhost:9130", Backend: idpBackend,
}, },
{ {
Endpoint: "/archiver", Endpoint: "/archiver",
Backend: "http://localhost:9140", Backend: revaBackend,
}, },
{ {
Endpoint: "/ocs/", Endpoint: "/ocs/",
Backend: "https://demo.owncloud.com", Backend: namedDemoBackend,
ApacheVHost: true, ApacheVHost: true,
}, },
{ {
Endpoint: "/remote.php/", Endpoint: "/remote.php/",
Backend: "https://demo.owncloud.com", Backend: namedDemoBackend,
ApacheVHost: true, ApacheVHost: true,
}, },
{ {
Endpoint: "/dav/", Endpoint: "/dav/",
Backend: "https://demo.owncloud.com", Backend: namedDemoBackend,
ApacheVHost: true, ApacheVHost: true,
}, },
{ {
Endpoint: "/webdav/", Endpoint: "/webdav/",
Backend: "https://demo.owncloud.com", Backend: namedDemoBackend,
ApacheVHost: true, ApacheVHost: true,
}, },
{ {
Endpoint: "/status.php", Endpoint: "/status.php",
Backend: "https://demo.owncloud.com", Backend: namedDemoBackend,
ApacheVHost: true, ApacheVHost: true,
}, },
{ {
Endpoint: "/index.php/", Endpoint: "/index.php/",
Backend: "https://demo.owncloud.com", Backend: namedDemoBackend,
ApacheVHost: true, ApacheVHost: true,
}, },
{ {
Endpoint: "/data", Endpoint: "/data",
Backend: "https://demo.owncloud.com", Backend: namedDemoBackend,
ApacheVHost: true, ApacheVHost: true,
}, },
}, },
+5 -3
View File
@@ -27,10 +27,12 @@ func Server(opts ...Option) (*http.Server, error) {
), nil ), nil
} }
const contentTypeHeader = "Content-Type"
// health implements the health check. // health implements the health check.
func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) { func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain") w.Header().Set(contentTypeHeader, "text/plain")
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
// TODO(tboerger): check if services are up and running // TODO(tboerger): check if services are up and running
@@ -44,7 +46,7 @@ func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
// ready implements the ready check. // ready implements the ready check.
func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) { func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/plain") w.Header().Set(contentTypeHeader, "text/plain")
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
// TODO(tboerger): check if services are up and running // TODO(tboerger): check if services are up and running
@@ -58,7 +60,7 @@ func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
// configDump implements the config dump // configDump implements the config dump
func configDump(cfg *config.Config) func(http.ResponseWriter, *http.Request) { func configDump(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json") w.Header().Set(contentTypeHeader, "application/json")
b, err := json.Marshal(cfg) b, err := json.Marshal(cfg)
if err != nil { if err != nil {
-1
View File
@@ -220,7 +220,6 @@ type StorageConfig struct {
S3 DriverS3 S3 DriverS3
S3NG DriverS3NG S3NG DriverS3NG
OCIS DriverOCIS OCIS DriverOCIS
// TODO checksums ... figure out what that is supposed to do
} }
// DriverCommon defines common driver configuration options. // DriverCommon defines common driver configuration options.