mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-06 04:09:40 -06:00
use go-chi middlewares
go-chi already delivers the middlewares we need so we don't need to import other libraries for that.
This commit is contained in:
@@ -2,6 +2,7 @@ package http
|
||||
|
||||
import (
|
||||
"github.com/asim/go-micro/v3"
|
||||
chimiddleware "github.com/go-chi/chi/middleware"
|
||||
graphMiddleware "github.com/owncloud/ocis/graph/pkg/middleware"
|
||||
svc "github.com/owncloud/ocis/graph/pkg/service/v0"
|
||||
"github.com/owncloud/ocis/graph/pkg/version"
|
||||
@@ -28,7 +29,7 @@ func Server(opts ...Option) (http.Service, error) {
|
||||
svc.Logger(options.Logger),
|
||||
svc.Config(options.Config),
|
||||
svc.Middleware(
|
||||
middleware.RequestID,
|
||||
chimiddleware.RequestID,
|
||||
middleware.Version(
|
||||
"graph",
|
||||
version.String,
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-chi/chi/middleware"
|
||||
"github.com/go-chi/render"
|
||||
"github.com/ascarter/requestid"
|
||||
msgraph "github.com/owncloud/open-graph-api-go"
|
||||
)
|
||||
|
||||
@@ -72,13 +72,12 @@ func (e ErrorCode) Render(w http.ResponseWriter, r *http.Request, status int, ms
|
||||
"date": time.Now().UTC().Format(time.RFC3339),
|
||||
// TODO return client-request-id?
|
||||
}
|
||||
if id, ok := requestid.FromContext(r.Context()); ok {
|
||||
innererror["request-id"] = id
|
||||
}
|
||||
|
||||
innererror["request-id"] = middleware.GetReqID(r.Context())
|
||||
resp := &msgraph.OdataError{
|
||||
Error: msgraph.OdataErrorMain{
|
||||
Code: e.String(),
|
||||
Message: msg,
|
||||
Code: e.String(),
|
||||
Message: msg,
|
||||
Innererror: &innererror,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user