Skip to content

Commit 0972c21

Browse files
Zones GET endpoint (#21)
* added skeleton for zones GET endpoint * updated env sample file * added database retrieval * modified route * updated docker-compose * modified route * fixed docker-compose file
1 parent e8d092a commit 0972c21

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

.env.sample

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
HOST_NAME=""
21
USER_NAME=""
32
PASSWD=""

Controllers/ZonesController.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
11
using Microsoft.AspNetCore.Mvc;
2-
2+
using StackExchange.Redis;
33

44
public class ZonesController : ControllerBase
55
{
6-
[HttpGet("{keepIn}")]
6+
private ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost");
7+
private readonly IDatabase _redis;
8+
9+
public ZonesController () {
10+
_redis = redis.GetDatabase();
11+
}
12+
13+
[HttpGet("zones/{keepIn}")]
714
public String getZones(string keepIn) {
815
if (keepIn.ToLower() == "in") {
916
// return keep-in zones
10-
return "in";
17+
return _redis.StringGet("keepIn");
1118
}
1219

1320
// else return keep-out zones
14-
return "out";
21+
if (keepIn.ToLower() == "out") {
22+
// return keep-in zones
23+
return _redis.StringGet("keepOut");
24+
}
25+
26+
return "invalid zone name";
1527
}
28+
29+
1630
}

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ services:
1111
redis-commander:
1212
image: rediscommander/redis-commander:latest
1313
environment:
14-
- REDIS_HOSTS=${HOST_NAME:?error}
14+
- REDIS_HOSTS=local:redis:6379
1515
- HTTP_USER=${USER_NAME:?error}
1616
- HTTP_PASSWORD=${PASSWD:?error}
1717
ports:

0 commit comments

Comments
 (0)