add actions and auth

This commit is contained in:
2025-05-17 12:08:44 +07:00
parent 4bd18ee756
commit e1b342d12c
14 changed files with 487 additions and 246 deletions
+20 -2
View File
@@ -4,6 +4,7 @@ import (
"context"
"evening_detective/internal/app"
"evening_detective/internal/services"
"evening_detective/internal/services/story_service"
proto "evening_detective/proto"
"log"
"net"
@@ -12,6 +13,7 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/metadata"
)
func main() {
@@ -28,10 +30,17 @@ func main() {
if err != nil {
panic(err)
}
storyService, err := story_service.NewStoryService()
if err != nil {
panic(err)
}
proto.RegisterEveningDetectiveServer(
s,
app.NewServer(
services.NewServices(repository),
services.NewServices(
repository,
storyService,
),
),
)
// Serve gRPC server
@@ -50,7 +59,16 @@ func main() {
log.Fatalln("Failed to dial server:", err)
}
gwmux := runtime.NewServeMux()
gwmux := runtime.NewServeMux(
runtime.WithMetadata(func(ctx context.Context, request *http.Request) metadata.MD {
teamId := request.Header.Get("X-Id")
return metadata.Pairs("team-id", teamId)
}),
runtime.WithMetadata(func(ctx context.Context, request *http.Request) metadata.MD {
password := request.Header.Get("X-Password")
return metadata.Pairs("password", password)
}),
)
// Register Greeter
err = proto.RegisterEveningDetectiveHandler(context.Background(), gwmux, conn)
if err != nil {