You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, our http services use always use a (w http.ResponseWriter, r *http.Request) signature. While that pattern is used for http handlers it is not used for grpc handlers which use specific request and response objects, delegating the request parsing and writing to middlewares.
The command first creates the handler and then wraps it with tracing, logging and metrics middlewares which can now operate directly on the request and response parameters.
In the chi handler for graph we can parse the odata request using godata.ParseRequest(...) and pass that to the Service interface so it can sort, filter, select and expand the object as needed.
An example signature would be:
// the old service interfacefunc (gGraph) GetMe(w http.ResponseWriter, r*http.Request) {}
// the new signature should be concerned with concrete typesfunc (gGraph) GetMe(ctx context.Context, idstring) (libregraph.User, error) {}
// unfortunately, we need to pass along // - which filelds to select and expand, GRPC uses field/update mask, see https://aip.bybutter.com/161// - pagination, GRPC uses page_size and page_token, see https://aip.bybutter.com/158) and// - filtering, GRPC uses an [EBNF](https://aip.bybutter.com/assets/misc/ebnf-filtering.txt) based filter, see https://aip.bybutter.com/160func (gGraph) GetMe(ctx context.Context, idstring, fieldMaskstring) (libregraph.User, error) {}
// for listing this becomes clearer:func (gGraph) ListUsers(ctx context.Context, filter, fieldMask, page_tokenstring, pageSizeint) (libregraph.User, error) {}
maybe we can refactor the handlers one by one ... one challenge is that we would have to parse the query parameters in the http service but still hand them over to the business implementation. we would be implementing a protobuf like generated api and include filters and pagination. 🤔 but that would have to be able to express the odata filters.
Currently, our http services use always use a
(w http.ResponseWriter, r *http.Request)
signature. While that pattern is used for http handlers it is not used for grpc handlers which use specific request and response objects, delegating the request parsing and writing to middlewares.AFAICT
ocis-hello
shows the correct pattern to use:https://github.com/owncloud/ocis-hello/blob/edc8ef1d4b79dba29321cc70a3f6a20373d30f65/pkg/service/v0/service.go#L19-L21
Actually it should receive a Context as the first parameter, but anyway, the HTTP service is then created using chi by parsing the json and then calling the handler:
https://github.com/owncloud/ocis-hello/blob/edc8ef1d4b79dba29321cc70a3f6a20373d30f65/pkg/server/http/server.go#L92
The command first creates the handler and then wraps it with tracing, logging and metrics middlewares which can now operate directly on the request and response parameters.
https://github.com/owncloud/ocis-hello/blob/edc8ef1d4b79dba29321cc70a3f6a20373d30f65/pkg/command/server.go#L90-L107
In the chi handler for graph we can parse the odata request using
godata.ParseRequest(...)
and pass that to the Service interface so it can sort, filter, select and expand the object as needed.An example signature would be:
Then the service interface from
should become more meaningful...
The text was updated successfully, but these errors were encountered: