Skip to content

Commit 637a13c

Browse files
Merge pull request #4 from jimreesman/master
support POST instead of GET for /features/:featureKey/access
2 parents 83e71b2 + 72af194 commit 637a13c

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ This API does not ship with an authentication layer. You **should not** expose t
4949
- [`GET` /features/:featureKey](#get-featuresfeaturekey) - Get a single feature flag
5050
- [`DELETE` /features/:featureKey](#delete-featuresfeaturekey) - Delete a feature flag
5151
- [`PATCH` /features/:featureKey](#patch-featuresfeaturekey) - Update a feature flag
52-
- [`GET` /features/:featureKey/access](#get-featuresfeaturekeyaccess) - Check if someone has access to a feature
52+
- [`POST` /features/:featureKey/access](#get-featuresfeaturekeyaccess) - Check if someone has access to a feature
5353

5454
### API Documentation
5555
#### `GET` `/features`
@@ -249,9 +249,9 @@ Update a feature flag.
249249
Common reason:
250250
- the percentage must be between `0` and `100`
251251

252-
#### `GET` `/features/:featureKey/access`
252+
#### `POST` `/features/:featureKey/access`
253253
Check if a feature flag is enabled for a user or a list of groups.
254-
- Method: `GET`
254+
- Method: `POST`
255255
- Endpoint: `/features/:featureKey/access`
256256
- Input:
257257
The `Content-Type` HTTP header should be set to `application/json`

http/handlers_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,21 +179,21 @@ func TestAccessFeatureFlag(t *testing.T) {
179179

180180
// Access thanks to the user ID
181181
reader = strings.NewReader(`{"user":2}`)
182-
request, _ := http.NewRequest("GET", fmt.Sprintf("%s/%s/access", base, "homepage_v2"), reader)
182+
request, _ := http.NewRequest("POST", fmt.Sprintf("%s/%s/access", base, "homepage_v2"), reader)
183183
res, _ := http.DefaultClient.Do(request)
184184

185185
assertAccessToTheFeature(t, res)
186186

187187
// No access because of the user ID
188188
reader = strings.NewReader(`{"user":3}`)
189-
request, _ = http.NewRequest("GET", fmt.Sprintf("%s/%s/access", base, "homepage_v2"), reader)
189+
request, _ = http.NewRequest("POST", fmt.Sprintf("%s/%s/access", base, "homepage_v2"), reader)
190190
res, _ = http.DefaultClient.Do(request)
191191

192192
assertNoAccessToTheFeature(t, res)
193193

194194
// Access thanks to the group
195195
reader = strings.NewReader(`{"user":3, "groups":["dev", "foo"]}`)
196-
request, _ = http.NewRequest("GET", fmt.Sprintf("%s/%s/access", base, "homepage_v2"), reader)
196+
request, _ = http.NewRequest("POST", fmt.Sprintf("%s/%s/access", base, "homepage_v2"), reader)
197197
res, _ = http.DefaultClient.Do(request)
198198

199199
assertAccessToTheFeature(t, res)

http/routes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ func getRoutes(api *APIHandler) Routes {
4545
"/features/{featureKey}",
4646
api.FeatureShow,
4747
},
48-
// curl -H "Content-Type: application/json" -d '{"groups":"foo"}' -X GET http://localhost:8080/features/feature_test/access
48+
// curl -H "Content-Type: application/json" -X POST -d '{"groups":"foo"}' -X GET http://localhost:8080/features/feature_test/access
4949
Route{
5050
"FeatureAccess",
51-
"GET",
51+
"POST",
5252
"/features/{featureKey}/access",
5353
api.FeatureAccess,
5454
},

0 commit comments

Comments
 (0)