✨ 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
This commit is contained in:
24
pkg/greet/greet_v2.go
Normal file
24
pkg/greet/greet_v2.go
Normal file
@@ -0,0 +1,24 @@
|
||||
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 + "!"
|
||||
}
|
||||
Reference in New Issue
Block a user