2020-07-08 11:56:37 +00:00
|
|
|
package ui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
http_util "github.com/caos/zitadel/internal/api/http"
|
|
|
|
"github.com/caos/zitadel/internal/ui/console"
|
|
|
|
"github.com/caos/zitadel/internal/ui/login"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2020-08-31 06:49:35 +00:00
|
|
|
uiname = "ui"
|
2020-07-08 11:56:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
Port string
|
|
|
|
Login login.Config
|
|
|
|
Console console.Config
|
|
|
|
}
|
|
|
|
|
|
|
|
type UI struct {
|
|
|
|
port string
|
|
|
|
mux *http.ServeMux
|
|
|
|
}
|
|
|
|
|
|
|
|
func Create(config Config) *UI {
|
|
|
|
return &UI{
|
|
|
|
port: config.Port,
|
|
|
|
mux: http.NewServeMux(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (u *UI) RegisterHandler(prefix string, handler http.Handler) {
|
|
|
|
http_util.RegisterHandler(u.mux, prefix, handler)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (u *UI) Start(ctx context.Context) {
|
|
|
|
http_util.Serve(ctx, u.mux, u.port, uiname)
|
|
|
|
}
|