Skip to content

Commit 0130378

Browse files
committed
time window quickstart
1 parent ef9b8d7 commit 0130378

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
title: Enable features on a schedule in a Go Gin web application
3+
titleSuffix: Azure App Configuration
4+
description: Learn how to enable feature flags on a schedule in a Go Gin web application by using time window filters.
5+
ms.service: azure-app-configuration
6+
ms.devlang: golang
7+
author: linglingye
8+
ms.author: linglingye
9+
ms.topic: how-to
10+
ms.custom: devx-track-go, mode-other
11+
ms.date: 07/25/2025
12+
---
13+
14+
# Enable features on a schedule in a Go Gin web application
15+
16+
In this guide, you use the time window filter to enable a feature on a schedule for a Go Gin web application.
17+
18+
The example used in this article is based on the Go Gin web application introduced in the feature management [quickstart](./quickstart-feature-flag-go-gin.md). Before proceeding further, complete the quickstart to create a Go Gin web application with a *Beta* feature flag. Once completed, you must [add a time window filter](./howto-timewindow-filter.md) to the *Beta* feature flag in your App Configuration store.
19+
20+
## Prerequisites
21+
22+
- Create a [Go Gin web application with a feature flag](./quickstart-feature-flag-go-gin.md).
23+
- [Add a time window filter to the feature flag](./howto-timewindow-filter.md)
24+
- [Azure App Configuration Go provider](https://pkg.go.dev/github.com/Azure/AppConfiguration-GoProvider/azureappconfiguration) v1.1.0-beta.1 or later.
25+
26+
## Use the time window filter
27+
28+
You've added a time window filter for your *Beta* feature flag in the prerequisites. Next, you'll use the feature flag with the time window filter in your Go Gin web application.
29+
30+
The Go Feature Management library automatically supports built-in feature filters, including the time window filter. When you create a feature manager with the Azure App Configuration provider, time window filters are evaluated automatically without requiring additional configuration.
31+
32+
The existing code from the quickstart already handles time window filters through the feature manager:
33+
34+
```golang
35+
// Create feature flag provider
36+
featureFlagProvider, err := azappconfig.NewFeatureFlagProvider(appConfig)
37+
if err != nil {
38+
log.Fatalf("Error creating feature flag provider: %v", err)
39+
}
40+
41+
// Create feature manager (automatically supports built-in filters including TimeWindowFilter)
42+
featureManager, err := featuremanagement.NewFeatureManager(featureFlagProvider, nil)
43+
if err != nil {
44+
log.Fatalf("Error creating feature manager: %v", err)
45+
}
46+
```
47+
48+
The feature evaluation in your middleware will now respect the time window filter:
49+
50+
```golang
51+
func (app *WebApp) featureMiddleware() gin.HandlerFunc {
52+
return func(c *gin.Context) {
53+
// Check if Beta feature is enabled (TimeWindowFilter is automatically evaluated)
54+
betaEnabled, err := app.featureManager.IsEnabled("Beta")
55+
if err != nil {
56+
log.Printf("Error checking Beta feature: %v", err)
57+
betaEnabled = false
58+
}
59+
60+
// Store feature flag status for use in templates
61+
c.Set("betaEnabled", betaEnabled)
62+
c.Next()
63+
}
64+
}
65+
```
66+
67+
## Time window filter in action
68+
69+
Relaunch the application. If your current time is earlier than the start time set for the time window filter, the **Beta** menu item won't appear on the toolbar. This is because the *Beta* feature flag is disabled by the time window filter.
70+
71+
:::image type="content" source="./media/quickstarts/gin-app-feature-flag-before.png" alt-text="Screenshot of Gin web app with Beta menu hidden.":::
72+
73+
Once the start time has passed, refresh your browser a few times. You'll notice that the **Beta** menu item now appears. This is because the *Beta* feature flag is now enabled by the time window filter.
74+
75+
:::image type="content" source="./media/quickstarts/gin-app-feature-flag-after.png" alt-text="Screenshot of Gin web app with Beta menu.":::
76+
77+
## Next steps
78+
79+
To learn more about the feature filters, continue to the following documents.
80+
81+
> [!div class="nextstepaction"]
82+
> [Enable conditional features with feature filters](./howto-feature-filters.md)
83+
84+
> [!div class="nextstepaction"]
85+
> [Roll out features to targeted audience](./howto-targetingfilter.md)
86+
87+
For the full feature rundown of the Go feature management library, continue to the following document.
88+
89+
> [!div class="nextstepaction"]
90+
> [Go Feature Management reference](https://pkg.go.dev/github.com/microsoft/Featuremanagement-Go/featuremanagement)

articles/azure-app-configuration/howto-timewindow-filter.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ In this article, you learn how to add and configure a time window filter for you
5858

5959
- [ASP.NET Core](./howto-timewindow-filter-aspnet-core.md)
6060
- [JavaScript](./howto-timewindow-filter-javascript.md)
61+
- [Go Gin](./howto-timewindow-filter-go.md)
6162

6263
## Next steps
6364

0 commit comments

Comments
 (0)