Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
Refactor user and things handler
Browse files Browse the repository at this point in the history
Signed-off-by: felix.gateru <[email protected]>
  • Loading branch information
felixgateru committed Nov 27, 2023
1 parent c475973 commit e44aac1
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion things/api/http/channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
)

func groupsHandler(svc groups.Service, r *chi.Mux, logger logger.Logger) http.Handler {
func groupsHandler(svc groups.Service, r *chi.Mux, logger logger.Logger) *chi.Mux {
opts := []kithttp.ServerOption{
kithttp.ServerErrorEncoder(apiutil.LoggingErrorEncoder(logger, api.EncodeError)),
}
Expand Down
2 changes: 1 addition & 1 deletion things/api/http/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
)

func clientsHandler(svc things.Service, r *chi.Mux, logger mglog.Logger) http.Handler {
func clientsHandler(svc things.Service, r *chi.Mux, logger mglog.Logger) *chi.Mux {
opts := []kithttp.ServerOption{
kithttp.ServerErrorEncoder(apiutil.LoggingErrorEncoder(logger, api.EncodeError)),
}
Expand Down
4 changes: 2 additions & 2 deletions things/api/http/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (

// MakeHandler returns a HTTP handler for Things and Groups API endpoints.
func MakeHandler(tsvc things.Service, grps groups.Service, mux *chi.Mux, logger mglog.Logger, instanceID string) http.Handler {
clientsHandler(tsvc, mux, logger)
groupsHandler(grps, mux, logger)
mux = clientsHandler(tsvc, mux, logger)
mux = groupsHandler(grps, mux, logger)

mux.Get("/health", magistrala.Health("things", instanceID))
mux.Handle("/metrics", promhttp.Handler())
Expand Down
2 changes: 1 addition & 1 deletion users/api/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
)

// MakeHandler returns a HTTP handler for API endpoints.
func clientsHandler(svc users.Service, r *chi.Mux, logger mglog.Logger) http.Handler {
func clientsHandler(svc users.Service, r *chi.Mux, logger mglog.Logger) *chi.Mux {
opts := []kithttp.ServerOption{
kithttp.ServerErrorEncoder(apiutil.LoggingErrorEncoder(logger, api.EncodeError)),
}
Expand Down
2 changes: 1 addition & 1 deletion users/api/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
)

// MakeHandler returns a HTTP handler for Groups API endpoints.
func groupsHandler(svc groups.Service, r *chi.Mux, logger logger.Logger) http.Handler {
func groupsHandler(svc groups.Service, r *chi.Mux, logger logger.Logger) *chi.Mux {
opts := []kithttp.ServerOption{
kithttp.ServerErrorEncoder(apiutil.LoggingErrorEncoder(logger, api.EncodeError)),
}
Expand Down
4 changes: 2 additions & 2 deletions users/api/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (

// MakeHandler returns a HTTP handler for Users and Groups API endpoints.
func MakeHandler(cls users.Service, grps groups.Service, mux *chi.Mux, logger mglog.Logger, instanceID string) http.Handler {
clientsHandler(cls, mux, logger)
groupsHandler(grps, mux, logger)
mux = clientsHandler(cls, mux, logger)
mux = groupsHandler(grps, mux, logger)

mux.Get("/health", magistrala.Health("users", instanceID))
mux.Handle("/metrics", promhttp.Handler())
Expand Down

0 comments on commit e44aac1

Please sign in to comment.