mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-13 15:49:38 -06:00
* initial webfinger stub Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * add webfinger to proxy, return current host Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * some cleanup Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * allow passing multiple rel params Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * introduce interfaces Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * parse oidc auth token Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * add templating, drop chain, use map of relation providers Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * fix ocis url yaml Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * fix typos Co-authored-by: Dominik Schmidt <dschmidt@owncloud.com> * switch to userinfo claims Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * readme cleanup Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * add TODO.md with ideas Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * replace subject on authenticated request responses Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * Apply suggestions from code review Co-authored-by: Martin <github@diemattels.at> * markdown lint Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * return a 401 when bearer token expired, some more docs Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * Apply suggestions from code review Co-authored-by: Martin <github@diemattels.at> * fix docs Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * clarify env var Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * extract handler func Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * use correct service in reflex.conf Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * test relations Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * Update services/webfinger/pkg/config/config.go --------- Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> Co-authored-by: Dominik Schmidt <dschmidt@owncloud.com> Co-authored-by: Martin <github@diemattels.at>
64 lines
1.9 KiB
Go
64 lines
1.9 KiB
Go
package debug
|
|
|
|
import (
|
|
"io"
|
|
"net/http"
|
|
|
|
"github.com/owncloud/ocis/v2/ocis-pkg/service/debug"
|
|
"github.com/owncloud/ocis/v2/ocis-pkg/version"
|
|
"github.com/owncloud/ocis/v2/services/webfinger/pkg/config"
|
|
)
|
|
|
|
// Server initializes the debug service and server.
|
|
func Server(opts ...Option) (*http.Server, error) {
|
|
options := newOptions(opts...)
|
|
|
|
return debug.NewService(
|
|
debug.Logger(options.Logger),
|
|
debug.Name(options.Config.Service.Name),
|
|
debug.Version(version.GetString()),
|
|
debug.Address(options.Config.Debug.Addr),
|
|
debug.Token(options.Config.Debug.Token),
|
|
debug.Pprof(options.Config.Debug.Pprof),
|
|
debug.Zpages(options.Config.Debug.Zpages),
|
|
debug.Health(health(options.Config)),
|
|
debug.Ready(ready(options.Config)),
|
|
debug.CorsAllowedOrigins(options.Config.HTTP.CORS.AllowedOrigins),
|
|
debug.CorsAllowedMethods(options.Config.HTTP.CORS.AllowedMethods),
|
|
debug.CorsAllowedHeaders(options.Config.HTTP.CORS.AllowedHeaders),
|
|
debug.CorsAllowCredentials(options.Config.HTTP.CORS.AllowCredentials),
|
|
), nil
|
|
}
|
|
|
|
// health implements the health check.
|
|
func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "text/plain")
|
|
w.WriteHeader(http.StatusOK)
|
|
|
|
// TODO: check if services are up and running
|
|
|
|
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
|
// io.WriteString should not fail but if it does we want to know.
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
}
|
|
|
|
// ready implements the ready check.
|
|
func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "text/plain")
|
|
w.WriteHeader(http.StatusOK)
|
|
|
|
// TODO: check if services are up and running
|
|
|
|
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
|
// io.WriteString should not fail but if it does we want to know.
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
}
|