mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
The V2 Calls api endpoints have been added beneath fns: (#1203)
/fns/{fnID}/calls
/fns/{fnID}/calls/{callID}
The S3 implementation forces our hand as we if we want to list Calls
under a Fn, we have to use the FnID as a prefix on the object names,
which mean we need it to look up any Call. It also makes sense in
terms of resource hierarchy.
These endpoints can optionally be disabled (as other endpoints), if a
service provider needs to provide this functionality via other means.
The 'calls' test has been fully migrated to fn calls. This has been
done to reduce the copy pasta a bit, and on balance is ok as the
routes calls will be removed soon.
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func (s *Server) handleCallList(c *gin.Context) {
|
||||
func (s *Server) handleCallList1(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
var err error
|
||||
|
||||
@@ -26,7 +26,7 @@ func (s *Server) handleCallList(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
calls, err := s.logstore.GetCalls(ctx, &filter)
|
||||
calls, err := s.logstore.GetCalls1(ctx, &filter)
|
||||
|
||||
var nextCursor string
|
||||
if len(calls) > 0 && len(calls) == filter.PerPage {
|
||||
@@ -41,6 +41,30 @@ func (s *Server) handleCallList(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Server) handleCallList(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
var err error
|
||||
|
||||
fnID := c.MustGet(api.ParamFnID).(string)
|
||||
// TODO api.ParamRouteName needs to be escaped probably, since it has '/' a lot
|
||||
filter := models.CallFilter{FnID: fnID}
|
||||
filter.Cursor, filter.PerPage = pageParams(c, false) // ids are url safe
|
||||
|
||||
filter.FromTime, filter.ToTime, err = timeParams(c)
|
||||
if err != nil {
|
||||
handleV1ErrorResponse(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
calls, err := s.logstore.GetCalls(ctx, &filter)
|
||||
|
||||
if err != nil {
|
||||
handleErrorResponse(c, err)
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, calls)
|
||||
}
|
||||
|
||||
// "" gets parsed to a zero time, which is fine (ignored in query)
|
||||
func timeParams(c *gin.Context) (fromTime, toTime common.DateTime, err error) {
|
||||
fromStr := c.Query("from_time")
|
||||
|
||||
Reference in New Issue
Block a user