mirror of
https://tangled.org/evan.jarrett.net/at-container-registry
synced 2026-04-23 09:50:33 +00:00
begin embedded pds with xrpc endpoints and well-known
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
@@ -11,6 +12,7 @@ import (
|
||||
|
||||
"atcr.io/pkg/atproto"
|
||||
"atcr.io/pkg/hold"
|
||||
"atcr.io/pkg/hold/pds"
|
||||
indigooauth "github.com/bluesky-social/indigo/atproto/auth/oauth"
|
||||
|
||||
// Import storage drivers
|
||||
@@ -31,6 +33,30 @@ func main() {
|
||||
log.Fatalf("Failed to create hold service: %v", err)
|
||||
}
|
||||
|
||||
// Initialize embedded PDS if database path is configured
|
||||
var holdPDS *pds.HoldPDS
|
||||
var xrpcHandler *pds.XRPCHandler
|
||||
if cfg.Database.Path != "" {
|
||||
// Generate did:web from public URL
|
||||
holdDID := pds.GenerateDIDFromURL(cfg.Server.PublicURL)
|
||||
log.Printf("Initializing embedded PDS with DID: %s", holdDID)
|
||||
|
||||
// Initialize PDS with carstore and keys
|
||||
ctx := context.Background()
|
||||
holdPDS, err = pds.NewHoldPDS(ctx, holdDID, cfg.Server.PublicURL, cfg.Database.Path, cfg.Database.KeyPath)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to initialize embedded PDS: %v", err)
|
||||
}
|
||||
|
||||
// Create blob store adapter
|
||||
blobStore := pds.NewHoldServiceBlobStore(service, holdDID)
|
||||
|
||||
// Create XRPC handler
|
||||
xrpcHandler = pds.NewXRPCHandler(holdPDS, cfg.Server.PublicURL, blobStore)
|
||||
|
||||
log.Printf("Embedded PDS initialized successfully")
|
||||
}
|
||||
|
||||
// Setup HTTP routes
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/health", service.HealthHandler)
|
||||
@@ -118,6 +144,12 @@ func main() {
|
||||
}
|
||||
})
|
||||
|
||||
// Register XRPC/ATProto PDS endpoints if PDS is initialized
|
||||
if xrpcHandler != nil {
|
||||
log.Printf("Registering ATProto PDS endpoints")
|
||||
xrpcHandler.RegisterHandlers(mux)
|
||||
}
|
||||
|
||||
// Create server
|
||||
server := &http.Server{
|
||||
Addr: cfg.Server.Addr,
|
||||
|
||||
Reference in New Issue
Block a user