aboutsummaryrefslogtreecommitdiff
path: root/application_router.go
diff options
context:
space:
mode:
Diffstat (limited to 'application_router.go')
-rw-r--r--application_router.go28
1 files changed, 26 insertions, 2 deletions
diff --git a/application_router.go b/application_router.go
index 30ec7c6..334e9f3 100644
--- a/application_router.go
+++ b/application_router.go
@@ -283,12 +283,36 @@ func CreateApplicationRouter(applicationContext *ApplicationContext,
badRequest(c, err)
return
}
- var format QueryFormat
+ var format GetMessageFormat
if err := c.ShouldBindQuery(&format); err != nil {
badRequest(c, err)
return
}
- success(c, applicationContext.ConnectionStreamsController.GetConnectionPayload(c, id, format))
+
+ if messages, found := applicationContext.ConnectionStreamsController.GetConnectionMessages(c, id, format); !found {
+ notFound(c, gin.H{"connection": id})
+ } else {
+ success(c, messages)
+ }
+ })
+
+ api.GET("/streams/:id/download", func(c *gin.Context) {
+ id, err := RowIDFromHex(c.Param("id"))
+ if err != nil {
+ badRequest(c, err)
+ return
+ }
+ var format DownloadMessageFormat
+ if err := c.ShouldBindQuery(&format); err != nil {
+ badRequest(c, err)
+ return
+ }
+
+ if blob, found := applicationContext.ConnectionStreamsController.DownloadConnectionMessages(c, id, format); !found {
+ notFound(c, gin.H{"connection": id})
+ } else {
+ c.String(http.StatusOK, blob)
+ }
})
api.GET("/services", func(c *gin.Context) {