Skip to content

Commit 276efdf

Browse files
committed
update
1 parent af2d605 commit 276efdf

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

articles/azure-app-configuration/howto-targetingfilter-go.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,27 @@ func loadAzureAppConfiguration(ctx context.Context) (*azureappconfiguration.Azur
326326
1. Create a file named `main.go` with the following content.
327327

328328
```golang
329+
package main
330+
331+
import (
332+
"context"
333+
"fmt"
334+
"log"
335+
"net/http"
336+
"strings"
337+
338+
"github.com/gin-contrib/sessions"
339+
"github.com/gin-contrib/sessions/cookie"
340+
"github.com/gin-gonic/gin"
341+
"github.com/microsoft/Featuremanagement-Go/featuremanagement"
342+
"github.com/microsoft/Featuremanagement-Go/featuremanagement/providers/azappconfig"
343+
)
344+
345+
type WebApp struct {
346+
featureManager *featuremanagement.FeatureManager
347+
appConfig *azureappconfiguration.AzureAppConfiguration
348+
}
349+
329350
func main() {
330351
// Load Azure App Configuration
331352
appConfig, err := loadAzureAppConfiguration(context.Background())
@@ -355,12 +376,13 @@ func loadAzureAppConfiguration(ctx context.Context) (*azureappconfiguration.Azur
355376
r := gin.Default()
356377

357378
// Start server
358-
fmt.Println("Starting server on http://localhost:8080")
359-
fmt.Println("Open http://localhost:8080 in your browser")
360-
fmt.Println()
361379
if err := r.Run(":8080"); err != nil {
362380
log.Fatalf("Failed to start server: %v", err)
363381
}
382+
383+
fmt.Println("Starting server on http://localhost:8080")
384+
fmt.Println("Open http://localhost:8080 in your browser")
385+
fmt.Println()
364386
}
365387
```
366388

@@ -530,8 +552,9 @@ func loadAzureAppConfiguration(ctx context.Context) (*azureappconfiguration.Azur
530552
app.setupRoutes(r)
531553
532554
// Start server
533-
fmt.Println("Starting server on http://localhost:8080")
534-
555+
if err := r.Run(":8080"); err != nil {
556+
log.Fatalf("Failed to start server: %v", err)
557+
}
535558
// The rest of existing code
536559
// ... ...
537560
```
@@ -546,7 +569,6 @@ func loadAzureAppConfiguration(ctx context.Context) (*azureappconfiguration.Azur
546569
"fmt"
547570
"log"
548571
"net/http"
549-
"os"
550572
"strings"
551573
552574
"github.com/gin-contrib/sessions"
@@ -728,12 +750,13 @@ func loadAzureAppConfiguration(ctx context.Context) (*azureappconfiguration.Azur
728750
app.setupRoutes(r)
729751
730752
// Start server
731-
fmt.Println("Starting server on http://localhost:8080")
732-
fmt.Println("Open http://localhost:8080 in your browser")
733-
fmt.Println()
734753
if err := r.Run(":8080"); err != nil {
735754
log.Fatalf("Failed to start server: %v", err)
736755
}
756+
757+
fmt.Println("Starting server on http://localhost:8080")
758+
fmt.Println("Open http://localhost:8080 in your browser")
759+
fmt.Println()
737760
}
738761
```
739762

0 commit comments

Comments
 (0)