-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(qrcode): basic support for static redirects
- Loading branch information
Showing
8 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
src/Eurofurence.App.Server.Services/Abstractions/QrCode/IQrCodeService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Eurofurence.App.Server.Services.Abstractions.QrCode | ||
{ | ||
public interface IQrCodeService | ||
{ | ||
string GetTarget(string id); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/Eurofurence.App.Server.Services/Abstractions/QrCode/QrCodeConfiguration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Eurofurence.App.Server.Services.Abstractions.QrCode | ||
{ | ||
public class QrCodeConfiguration | ||
{ | ||
public Dictionary<string, string> Targets { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/Eurofurence.App.Server.Services/QrCode/QrCodeService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Eurofurence.App.Server.Services.Abstractions.QrCode; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace Eurofurence.App.Server.Services.Communication | ||
{ | ||
public class QrCodeService : IQrCodeService | ||
{ | ||
private readonly QrCodeConfiguration _qrCodeConfiguration; | ||
|
||
public QrCodeService( | ||
IOptionsMonitor<QrCodeConfiguration> qrCodeConfiguration | ||
) | ||
{ | ||
_qrCodeConfiguration = qrCodeConfiguration.CurrentValue; | ||
} | ||
public string GetTarget(string id) | ||
{ | ||
return _qrCodeConfiguration.Targets[id]; | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/Eurofurence.App.Server.Web/Controllers/QrCodeController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Eurofurence.App.Server.Services.Abstractions.QrCode; | ||
using Microsoft.AspNetCore.Mvc; | ||
using System; | ||
|
||
namespace Eurofurence.App.Server.Web.Controllers | ||
{ | ||
[Route("qr")] | ||
public class QrCodeController : BaseController | ||
{ | ||
private readonly IQrCodeService _qrCodeService; | ||
|
||
public QrCodeController( | ||
IQrCodeService qrCodeService | ||
) | ||
{ | ||
_qrCodeService = qrCodeService; | ||
} | ||
|
||
[HttpGet("{targetId}")] | ||
public ActionResult GetTargetRedirect(string targetId) | ||
{ | ||
try | ||
{ | ||
return new RedirectResult(_qrCodeService.GetTarget(targetId)); | ||
} | ||
catch (Exception) | ||
{ | ||
return NotFound(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.