Files
dance-lessons-coach/pkg/greet/greet_v2.go
Gabriel Radureau 875eb09fb7 feat: implement API v2 with feature flag control
- Added /api/v2/greet POST endpoint with JSON request/response

- Implemented ServiceV2 with Hello my friend <name>! greeting format

- Added api.v2_enabled feature flag (default: false)

- Extended BDD tests to cover v2 scenarios

- Maintained full backward compatibility with v1 API

- Added DLC_API_V2_ENABLED environment variable support

- Created ADR 0010-api-v2-feature-flag.md

- Updated configuration system to support API versioning
2026-04-04 20:39:46 +02:00

24 lines
560 B
Go

package greet
import (
"context"
"github.com/rs/zerolog/log"
)
type ServiceV2 struct{}
func NewServiceV2() *ServiceV2 {
return &ServiceV2{}
}
// GreetV2 returns a v2 greeting message for the given name.
// If name is empty, it defaults to "friend".
// This is the v2 implementation that returns "Hello my friend <name>!"
func (s *ServiceV2) GreetV2(ctx context.Context, name string) string {
log.Trace().Ctx(ctx).Str("name", name).Msg("GreetV2 function called")
if name == "" {
return "Hello my friend!"
}
return "Hello my friend " + name + "!"
}