Skip to content

Commit

Permalink
moved http registry in rhttp pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
gmgigi96 committed Jul 12, 2023
1 parent b999edb commit 1a85e5f
Show file tree
Hide file tree
Showing 24 changed files with 98 additions and 130 deletions.
6 changes: 3 additions & 3 deletions cmd/revad/runtime/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/cs3org/reva/internal/http/interceptors/appctx"
"github.com/cs3org/reva/internal/http/interceptors/auth"
"github.com/cs3org/reva/internal/http/interceptors/log"
"github.com/cs3org/reva/pkg/rhttp/global"
"github.com/cs3org/reva/pkg/rhttp"
"github.com/cs3org/reva/pkg/rhttp/mux"
"github.com/pkg/errors"
"github.com/rs/zerolog"
Expand All @@ -35,13 +35,13 @@ import (
type middlewareTriple struct {
Name string
Priority int
Middleware global.Middleware
Middleware rhttp.Middleware
}

func initHTTPMiddlewares(conf map[string]map[string]any, logger *zerolog.Logger) (func(*mux.Options) []mux.Middleware, error) {
triples := []*middlewareTriple{}
for name, c := range conf {
new, ok := global.NewMiddlewares[name]
new, ok := rhttp.NewMiddlewares[name]
if !ok {
continue
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/revad/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
"github.com/cs3org/reva/pkg/rgrpc"
"github.com/cs3org/reva/pkg/rhttp"

"github.com/cs3org/reva/pkg/rhttp/global"
"github.com/cs3org/reva/pkg/rserverless"
"github.com/cs3org/reva/pkg/sharedconf"
rtrace "github.com/cs3org/reva/pkg/trace"
Expand Down Expand Up @@ -461,7 +460,7 @@ func newServers(ctx context.Context, grpc []*config.GRPC, http []*config.HTTP, l
server := &Server{
server: s,
listener: ln,
services: maps.MapValues(services, func(s global.Service) any { return s }),
services: maps.MapValues(services, func(s rhttp.Service) any { return s }),
}
log.Debug().
Interface("services", maps.Keys(cfg.Services)).
Expand Down
4 changes: 2 additions & 2 deletions internal/http/interceptors/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
"github.com/cs3org/reva/pkg/errtypes"
"github.com/cs3org/reva/pkg/rgrpc/status"
"github.com/cs3org/reva/pkg/rgrpc/todo/pool"
"github.com/cs3org/reva/pkg/rhttp/global"
"github.com/cs3org/reva/pkg/rhttp"
"github.com/cs3org/reva/pkg/sharedconf"
"github.com/cs3org/reva/pkg/token"
tokenmgr "github.com/cs3org/reva/pkg/token/manager/registry"
Expand Down Expand Up @@ -77,7 +77,7 @@ func parseConfig(m map[string]interface{}) (*config, error) {
}

// New returns a new middleware with defined priority.
func New(m map[string]interface{}) (global.Middleware, error) {
func New(m map[string]interface{}) (rhttp.Middleware, error) {
conf, err := parseConfig(m)
if err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions internal/http/interceptors/cors/cors.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package cors
import (
"net/http"

"github.com/cs3org/reva/pkg/rhttp/global"
"github.com/cs3org/reva/pkg/rhttp"
"github.com/mitchellh/mapstructure"
"github.com/rs/cors"
)
Expand All @@ -31,7 +31,7 @@ const (
)

func init() {
global.RegisterMiddleware("cors", New)
rhttp.RegisterMiddleware("cors", New)
}

type config struct {
Expand All @@ -47,7 +47,7 @@ type config struct {
}

// New creates a new CORS middleware.
func New(m map[string]interface{}) (global.Middleware, int, error) {
func New(m map[string]interface{}) (rhttp.Middleware, int, error) {
conf := &config{}
if err := mapstructure.Decode(m, conf); err != nil {
return nil, 0, err
Expand Down
5 changes: 2 additions & 3 deletions internal/http/services/appprovider/appprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
"github.com/cs3org/reva/pkg/rgrpc/status"
"github.com/cs3org/reva/pkg/rgrpc/todo/pool"
"github.com/cs3org/reva/pkg/rhttp"
"github.com/cs3org/reva/pkg/rhttp/global"
"github.com/cs3org/reva/pkg/rhttp/mux"
"github.com/cs3org/reva/pkg/sharedconf"
"github.com/cs3org/reva/pkg/utils"
Expand All @@ -47,7 +46,7 @@ import (
const name = "appprovider"

func init() {
global.Register(name, New)
rhttp.Register(name, New)
}

// Config holds the config options for the HTTP appprovider service.
Expand All @@ -66,7 +65,7 @@ type svc struct {
}

// New returns a new ocmd object.
func New(ctx context.Context, m map[string]interface{}) (global.Service, error) {
func New(ctx context.Context, m map[string]interface{}) (rhttp.Service, error) {
var c Config
if err := cfg.Decode(m, &c); err != nil {
return nil, err
Expand Down
5 changes: 2 additions & 3 deletions internal/http/services/archiver/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"github.com/cs3org/reva/pkg/errtypes"
"github.com/cs3org/reva/pkg/rgrpc/todo/pool"
"github.com/cs3org/reva/pkg/rhttp"
"github.com/cs3org/reva/pkg/rhttp/global"
"github.com/cs3org/reva/pkg/rhttp/mux"
"github.com/cs3org/reva/pkg/sharedconf"
"github.com/cs3org/reva/pkg/storage/utils/downloader"
Expand Down Expand Up @@ -68,11 +67,11 @@ type Config struct {
}

func init() {
global.Register(name, New)
rhttp.Register(name, New)
}

// New creates a new archiver service.
func New(ctx context.Context, conf map[string]interface{}) (global.Service, error) {
func New(ctx context.Context, conf map[string]interface{}) (rhttp.Service, error) {
var c Config
if err := cfg.Decode(conf, &c); err != nil {
return nil, err
Expand Down
5 changes: 2 additions & 3 deletions internal/http/services/datagateway/datagateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/errtypes"
"github.com/cs3org/reva/pkg/rhttp"
"github.com/cs3org/reva/pkg/rhttp/global"
"github.com/cs3org/reva/pkg/rhttp/mux"
"github.com/cs3org/reva/pkg/sharedconf"
"github.com/cs3org/reva/pkg/utils/cfg"
Expand All @@ -48,7 +47,7 @@ const (
)

func init() {
global.Register(name, New)
rhttp.Register(name, New)
}

// transferClaims are custom claims for a JWT token to be used between the metadata and data gateways.
Expand All @@ -73,7 +72,7 @@ type svc struct {
}

// New returns a new datagateway.
func New(ctx context.Context, m map[string]interface{}) (global.Service, error) {
func New(ctx context.Context, m map[string]interface{}) (rhttp.Service, error) {
var c config
if err := cfg.Decode(m, &c); err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions internal/http/services/dataprovider/dataprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"fmt"
"net/http"

"github.com/cs3org/reva/pkg/rhttp"
datatxregistry "github.com/cs3org/reva/pkg/rhttp/datatx/manager/registry"
"github.com/cs3org/reva/pkg/rhttp/global"
"github.com/cs3org/reva/pkg/rhttp/mux"
"github.com/cs3org/reva/pkg/storage"
"github.com/cs3org/reva/pkg/storage/fs/registry"
Expand All @@ -34,7 +34,7 @@ import (
const name = "dataprovider"

func init() {
global.Register(name, New)
rhttp.Register(name, New)
}

type config struct {
Expand All @@ -58,7 +58,7 @@ type svc struct {
}

// New returns a new datasvc.
func New(ctx context.Context, m map[string]interface{}) (global.Service, error) {
func New(ctx context.Context, m map[string]interface{}) (rhttp.Service, error) {
var c config
if err := cfg.Decode(m, &c); err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions internal/http/services/helloworld/helloworld.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ import (
"net/http"

"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/rhttp/global"
"github.com/cs3org/reva/pkg/rhttp"
"github.com/cs3org/reva/pkg/rhttp/mux"
"github.com/cs3org/reva/pkg/utils/cfg"
)

const name = "helloworld"

func init() {
global.Register(name, New)
rhttp.Register(name, New)
}

// New returns a new helloworld service.
func New(ctx context.Context, m map[string]interface{}) (global.Service, error) {
func New(ctx context.Context, m map[string]interface{}) (rhttp.Service, error) {
var c config
if err := cfg.Decode(m, &c); err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions internal/http/services/mentix/mentix.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ import (
"github.com/cs3org/reva/pkg/mentix/config"
"github.com/cs3org/reva/pkg/mentix/exchangers"
"github.com/cs3org/reva/pkg/mentix/meshdata"
"github.com/cs3org/reva/pkg/rhttp/global"
"github.com/cs3org/reva/pkg/rhttp"
"github.com/cs3org/reva/pkg/rhttp/mux"
"github.com/cs3org/reva/pkg/utils/cfg"
"github.com/pkg/errors"
"github.com/rs/zerolog"
)

func init() {
global.Register(serviceName, New)
rhttp.Register(serviceName, New)
}

type svc struct {
Expand Down Expand Up @@ -155,7 +155,7 @@ func applyDefaultConfig(conf *config.Configuration) {
}

// New returns a new Mentix service.
func New(ctx context.Context, m map[string]interface{}) (global.Service, error) {
func New(ctx context.Context, m map[string]interface{}) (rhttp.Service, error) {
var c config.Configuration
if err := cfg.Decode(m, &c); err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions internal/http/services/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ import (
"github.com/cs3org/reva/pkg/logger"
"github.com/cs3org/reva/pkg/metrics"
"github.com/cs3org/reva/pkg/metrics/config"
"github.com/cs3org/reva/pkg/rhttp/global"
"github.com/cs3org/reva/pkg/rhttp"
"github.com/cs3org/reva/pkg/rhttp/mux"
"github.com/cs3org/reva/pkg/utils/cfg"
)

func init() {
global.Register(serviceName, New)
rhttp.Register(serviceName, New)
}

const (
Expand Down Expand Up @@ -64,7 +64,7 @@ func (s *svc) Register(r mux.Router) {
}

// New returns a new metrics service.
func New(ctx context.Context, m map[string]interface{}) (global.Service, error) {
func New(ctx context.Context, m map[string]interface{}) (rhttp.Service, error) {
var c config.Config
if err := cfg.Decode(m, &c); err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions internal/http/services/ocmd/ocm.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"context"
"net/http"

"github.com/cs3org/reva/pkg/rhttp/global"
"github.com/cs3org/reva/pkg/rhttp"
"github.com/cs3org/reva/pkg/rhttp/mux"
"github.com/cs3org/reva/pkg/sharedconf"
"github.com/cs3org/reva/pkg/utils/cfg"
Expand All @@ -31,7 +31,7 @@ import (
const name = "ocmd"

func init() {
global.Register(name, New)
rhttp.Register(name, New)
}

type config struct {
Expand All @@ -52,7 +52,7 @@ type svc struct {

// New returns a new ocmd object, that implements
// the OCM APIs specified in https://cs3org.github.io/OCM-API/docs.html
func New(ctx context.Context, m map[string]interface{}) (global.Service, error) {
func New(ctx context.Context, m map[string]interface{}) (rhttp.Service, error) {
var c config
if err := cfg.Decode(m, &c); err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions internal/http/services/ocmprovider/ocmprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ import (
"net/http"

"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/rhttp/global"
"github.com/cs3org/reva/pkg/rhttp"
"github.com/cs3org/reva/pkg/rhttp/mux"
"github.com/cs3org/reva/pkg/utils/cfg"
)

const name = "ocmprovider"

func init() {
global.Register(name, New)
rhttp.Register(name, New)
}

type config struct {
Expand Down Expand Up @@ -128,7 +128,7 @@ func (c *config) prepare() *discoveryData {
// New returns a new ocmprovider object, that implements
// the OCM discovery endpoint specified in
// https://cs3org.github.io/OCM-API/docs.html?repo=OCM-API&user=cs3org#/paths/~1ocm-provider/get
func New(ctx context.Context, m map[string]interface{}) (global.Service, error) {
func New(ctx context.Context, m map[string]interface{}) (rhttp.Service, error) {
var c config
if err := cfg.Decode(m, &c); err != nil {
return nil, err
Expand Down
5 changes: 2 additions & 3 deletions internal/http/services/owncloud/ocdav/ocdav.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
"github.com/cs3org/reva/pkg/notification/notificationhelper"
"github.com/cs3org/reva/pkg/rgrpc/todo/pool"
"github.com/cs3org/reva/pkg/rhttp"
"github.com/cs3org/reva/pkg/rhttp/global"
"github.com/cs3org/reva/pkg/rhttp/mux"
"github.com/cs3org/reva/pkg/sharedconf"
"github.com/cs3org/reva/pkg/storage/favorite"
Expand Down Expand Up @@ -83,7 +82,7 @@ func (r nameDoesNotContain) Test(name string) bool {
}

func init() {
global.Register(name, New)
rhttp.Register(name, New)
}

// Config holds the config options that need to be passed down to all ocdav handlers.
Expand Down Expand Up @@ -145,7 +144,7 @@ func getFavoritesManager(c *Config) (favorite.Manager, error) {
}

// New returns a new ocdav.
func New(ctx context.Context, m map[string]interface{}) (global.Service, error) {
func New(ctx context.Context, m map[string]interface{}) (rhttp.Service, error) {
var c Config
if err := cfg.Decode(m, &c); err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions internal/http/services/owncloud/ocs/ocs.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
configHandler "github.com/cs3org/reva/internal/http/services/owncloud/ocs/handlers/config"
"github.com/cs3org/reva/internal/http/services/owncloud/ocs/response"
"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/rhttp/global"
"github.com/cs3org/reva/pkg/rhttp"
"github.com/cs3org/reva/pkg/rhttp/mux"
"github.com/cs3org/reva/pkg/utils/cfg"
"github.com/rs/zerolog"
Expand All @@ -42,7 +42,7 @@ import (
const name = "ocs"

func init() {
global.Register(name, New)
rhttp.Register(name, New)
}

type svc struct {
Expand All @@ -57,7 +57,7 @@ type svc struct {
shareesHandler *sharees.Handler
}

func New(ctx context.Context, m map[string]interface{}) (global.Service, error) {
func New(ctx context.Context, m map[string]interface{}) (rhttp.Service, error) {
var c config.Config
if err := cfg.Decode(m, &c); err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions internal/http/services/preferences/preferences.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/rgrpc/todo/pool"
"github.com/cs3org/reva/pkg/rhttp/global"
"github.com/cs3org/reva/pkg/rhttp"
"github.com/cs3org/reva/pkg/rhttp/mux"
"github.com/cs3org/reva/pkg/sharedconf"
"github.com/cs3org/reva/pkg/utils/cfg"
Expand All @@ -36,7 +36,7 @@ import (
const name = "preferences"

func init() {
global.Register(name, New)
rhttp.Register(name, New)
}

// Config holds the config options that for the preferences HTTP service.
Expand All @@ -53,7 +53,7 @@ type svc struct {
}

// New returns a new ocmd object.
func New(ctx context.Context, m map[string]interface{}) (global.Service, error) {
func New(ctx context.Context, m map[string]interface{}) (rhttp.Service, error) {
var c Config
if err := cfg.Decode(m, &c); err != nil {
return nil, err
Expand Down
Loading

0 comments on commit 1a85e5f

Please sign in to comment.