mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-14 20:48:44 +00:00
feat: add initial implementation of osiris, the TLS terminator for Anubis
Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
37
cmd/osiris/internal/entrypoint/entrypoint.go
Normal file
37
cmd/osiris/internal/entrypoint/entrypoint.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package entrypoint
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
|
||||
"github.com/TecharoHQ/anubis/cmd/osiris/internal/config"
|
||||
"github.com/TecharoHQ/anubis/internal"
|
||||
"github.com/hashicorp/hcl/v2/hclsimple"
|
||||
healthv1 "google.golang.org/grpc/health/grpc_health_v1"
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
ConfigFname string
|
||||
}
|
||||
|
||||
func Main(opts Options) error {
|
||||
internal.SetHealth("osiris", healthv1.HealthCheckResponse_NOT_SERVING)
|
||||
|
||||
var cfg config.Toplevel
|
||||
if err := hclsimple.DecodeFile(opts.ConfigFname, nil, &cfg); err != nil {
|
||||
return fmt.Errorf("can't read configuration file %s:\n\n%w", opts.ConfigFname, err)
|
||||
}
|
||||
|
||||
if err := cfg.Valid(); err != nil {
|
||||
return fmt.Errorf("configuration file %s is invalid:\n\n%w", opts.ConfigFname, err)
|
||||
}
|
||||
|
||||
rtr, err := NewRouter(cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
slog.Info("listening on", "http", cfg.Bind.HTTP)
|
||||
return http.ListenAndServe(cfg.Bind.HTTP, rtr)
|
||||
}
|
||||
Reference in New Issue
Block a user