mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
this patch has no behavior changes, changes are: * server.Datastore() -> server.datastore * server.MQ -> server.mq * server.LogDB -> server.logstore * server.Agent -> server.agent these were at a minimum not uniform. further, it's probably better to force configuration through initialization in `server.New` to ensure thread safety of referencing if someone does want to modify these as well as forcing things into our initialization path and reducing the surface area of the Server abstraction.
39 lines
879 B
Go
39 lines
879 B
Go
package server
|
|
|
|
import (
|
|
"bytes"
|
|
"net/http"
|
|
|
|
"github.com/fnproject/fn/api"
|
|
"github.com/fnproject/fn/api/models"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func (s *Server) handleCallLogGet(c *gin.Context) {
|
|
ctx := c.Request.Context()
|
|
|
|
appName := c.MustGet(api.AppName).(string)
|
|
callID := c.Param(api.Call)
|
|
|
|
logReader, err := s.logstore.GetLog(ctx, appName, callID)
|
|
if err != nil {
|
|
handleErrorResponse(c, err)
|
|
return
|
|
}
|
|
|
|
// TODO this API needs to change to text/plain / gzip anyway, punting
|
|
// optimization, but we can write this direct to the wire, too... seems like
|
|
// we should write some kind of writev json thing for go since we keep
|
|
// hitting this :(
|
|
var b bytes.Buffer
|
|
b.ReadFrom(logReader)
|
|
|
|
callObj := models.CallLog{
|
|
CallID: callID,
|
|
AppName: appName,
|
|
Log: b.String(),
|
|
}
|
|
|
|
c.JSON(http.StatusOK, callLogResponse{"Successfully loaded log", &callObj})
|
|
}
|