Skip to content

Commit

Permalink
feature(api,ssh,pkg): add events to sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
henrybarreto authored and gustavosbarreto committed Nov 28, 2024
1 parent cfb357a commit 37e67c9
Show file tree
Hide file tree
Showing 17 changed files with 378 additions and 293 deletions.
1 change: 1 addition & 0 deletions api/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func NewRouter(service services.Service, opts ...Option) *echo.Echo {
internalAPI.GET(GetPublicKeyURL, gateway.Handler(handler.GetPublicKey))
internalAPI.POST(CreatePrivateKeyURL, gateway.Handler(handler.CreatePrivateKey))
internalAPI.POST(EvaluateKeyURL, gateway.Handler(handler.EvaluateKey))
internalAPI.POST(EventsSessionsURL, gateway.Handler(handler.EventSession))

// Public routes for external access through API gateway
publicAPI := e.Group("/api")
Expand Down
18 changes: 18 additions & 0 deletions api/routes/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
KeepAliveSessionURL = "/sessions/:uid/keepalive"
RecordSessionURL = "/sessions/:uid/record"
PlaySessionURL = "/sessions/:uid/play"
EventsSessionsURL = "/sessions/:uid/events"
)

const (
Expand Down Expand Up @@ -133,3 +134,20 @@ func (h *Handler) PlaySession(c gateway.Context) error {
func (h *Handler) DeleteRecordedSession(c gateway.Context) error {
return c.NoContent(http.StatusOK)
}

func (h *Handler) EventSession(c gateway.Context) error {
var req requests.SessionEvent
if err := c.Bind(&req); err != nil {
return err
}

if err := c.Validate(&req); err != nil {
return err
}

return h.service.EventSession(c.Ctx(), models.UID(req.UID), &models.SessionEvent{
Type: req.Type,
Timestamp: req.Timestamp,
Data: req.Data,
})
}
Loading

0 comments on commit 37e67c9

Please sign in to comment.