func NewRequestHandler(
	gwClient pbGRPC.GrpcGatewayClient,
	raClient *raClient.Client,
	subMgr *SubscriptionManager,
	emitEvent emitEventFunc,
) *RequestHandler {
	return &RequestHandler{
		gwClient:  gwClient,
		raClient:  raClient,
		subMgr:    subMgr,
		emitEvent: emitEvent,
	}
}
NewRequestHandler factory for new RequestHandler
package service
import (
	"context"
	"fmt"
	"net/http"
	"net/url"
	"strings"
	"github.com/plgd-dev/go-coap/v2/message"
	"github.com/plgd-dev/kit/v2/codec/cbor"
	"github.com/plgd-dev/kit/v2/codec/json"
	"github.com/plgd-dev/hub/cloud2cloud-connector/events"
	"github.com/plgd-dev/hub/cloud2cloud-gateway/uri"
	kitNetHttp "github.com/plgd-dev/hub/pkg/net/http"
	raClient "github.com/plgd-dev/hub/resource-aggregate/client"
	"github.com/plgd-dev/kit/v2/log"
	router "github.com/gorilla/mux"
	pbGRPC "github.com/plgd-dev/hub/grpc-gateway/pb"
)
const HrefKey = "Href"
const subscriptionIDKey = "subscriptionID"
const deviceIDKey = "deviceID"
const ContentQuery = "content"
const ContentQueryBaseValue = "base"
const ContentQueryAllValue = "all"
const ContentQueryDefault = ContentQueryBaseValue
type ListDevicesOfUserFunc func(ctx context.Context, correlationID, userID, accessToken string) (deviceIds []string, statusCode int, err error)
type RequestHandler struct {
	gwClient  pbGRPC.GrpcGatewayClient
	raClient  *raClient.Client
	subMgr    *SubscriptionManager
	emitEvent emitEventFunc
}
func logAndWriteErrorResponse(err error, statusCode int, w http.ResponseWriter) {
	log.Errorf("%v", err)
	w.Header().Set(events.ContentTypeKey, "text/plain")
	w.WriteHeader(kitNetHttp.ErrToStatusWithDef(err, statusCode))
	if _, err2 := w.Write([]byte(err.Error())); err2 != nil {
		log.Errorf("failed to write error response body: %w", err2)
	}
}