Skip to content

How to log RPC requests properly? #45

Description

@kochetkov-av

So far I've implemented a logger call inside each handler, which doesn't look like the best idea.

I think the best place to log requests is right after the parser, so it's really nice to have some kind of middleware support.

Probably somewhere in here?

jsonrpc/handler.go

Lines 45 to 53 in 352acaa

resp := make([]*Response, len(rs))
for i := range rs {
resp[i] = mr.InvokeMethod(r.Context(), rs[i])
}
if err := SendResponse(w, resp, batch); err != nil {
fmt.Fprint(w, "Failed to encode result objects")
w.WriteHeader(http.StatusInternalServerError)
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions