mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fn: remove redundant httprouter code (#532)
*) tree from https://github.com/julienschmidt/httprouter is already in Gin and this only seems to be parsing parameters from URI.
This commit is contained in:
committed by
Reed Allman
parent
d8a1431418
commit
89dc79f0b0
@@ -40,6 +40,16 @@ func (s *Server) handleRequest(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
// convert gin.Params to agent.Params to avoid introducing gin
|
||||
// dependency to agent
|
||||
func parseParams(params gin.Params) agent.Params {
|
||||
out := make(agent.Params, 0, len(params))
|
||||
for _, val := range params {
|
||||
out = append(out, agent.Param{Key: val.Key, Value: val.Value})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// TODO it would be nice if we could make this have nothing to do with the gin.Context but meh
|
||||
// TODO make async store an *http.Request? would be sexy until we have different api format...
|
||||
func (s *Server) serve(c *gin.Context, appName, path string) {
|
||||
@@ -47,7 +57,7 @@ func (s *Server) serve(c *gin.Context, appName, path string) {
|
||||
// strip params, etc.
|
||||
call, err := s.Agent.GetCall(
|
||||
agent.WithWriter(c.Writer), // XXX (reed): order matters [for now]
|
||||
agent.FromRequest(appName, path, c.Request),
|
||||
agent.FromRequest(appName, path, c.Request, parseParams(c.Params)),
|
||||
)
|
||||
if err != nil {
|
||||
handleErrorResponse(c, err)
|
||||
|
||||
Reference in New Issue
Block a user