-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (41 loc) · 1.16 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"fmt"
"log/slog"
"net/http"
"os"
"github.com/odrling/zitadel-karaberus/server/exampleop"
"github.com/odrling/zitadel-karaberus/server/storage"
)
func main() {
addr, found := os.LookupEnv("LISTEN_ADDR")
if !found {
addr = "127.0.0.1"
}
port, found := os.LookupEnv("LISTEN_PORT")
if !found {
port = "9998"
}
issuer := fmt.Sprintf("http://%s:%s", addr, port)
// the OpenIDProvider interface needs a Storage interface handling various checks and state manipulations
// this might be the layer for accessing your database
// in this example it will be handled in-memory
storage := storage.NewStorage(storage.NewUserStore(issuer))
logger := slog.New(
slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{
AddSource: true,
Level: slog.LevelDebug,
}),
)
router := exampleop.SetupServer(issuer, storage, logger, false)
server := &http.Server{
Addr: ":" + port,
Handler: router,
}
logger.Info("server listening, press ctrl+c to stop", "addr", fmt.Sprintf("http://localhost:%s/", port))
err := server.ListenAndServe()
if err != http.ErrServerClosed {
logger.Error("server terminated", "error", err)
os.Exit(1)
}
}