mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-28 13:48:49 +08:00

* Add open tracing dependencies Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com> * Add open tracing to users service Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com> * Add open tracing to the things service Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com> * Add open tracing to the http adapter Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com> * Add open tracing to the ws adapter Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com> * Add open tracing to the CoAP adapter Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com> * Update LoRa adapter in accordance with changes Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com> * Update SDK tests in accordance with changes Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com> * Update bootstrap service in accordance with changes Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com> * Update reader services with accordance with changes Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com> * Update .env and docker-compose file Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com> * Add jaeger and timeout env vars Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com> * Fix broken test for can access by id endpoint Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com> * Update deps with proto empty package Signed-off-by: Aleksandar Novakovic <anovakovic01@gmail.com>
46 lines
988 B
Go
46 lines
988 B
Go
//
|
|
// Copyright (c) 2019
|
|
// Mainflux
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
// Package http contains the domain concept definitions needed to support
|
|
// Mainflux http adapter service functionality.
|
|
package http
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/mainflux/mainflux"
|
|
)
|
|
|
|
var _ mainflux.MessagePublisher = (*adapterService)(nil)
|
|
|
|
type adapterService struct {
|
|
pub mainflux.MessagePublisher
|
|
things mainflux.ThingsServiceClient
|
|
}
|
|
|
|
// New instantiates the HTTP adapter implementation.
|
|
func New(pub mainflux.MessagePublisher, things mainflux.ThingsServiceClient) mainflux.MessagePublisher {
|
|
return &adapterService{
|
|
pub: pub,
|
|
things: things,
|
|
}
|
|
}
|
|
|
|
func (as *adapterService) Publish(ctx context.Context, token string, msg mainflux.RawMessage) error {
|
|
ar := &mainflux.AccessReq{
|
|
Token: token,
|
|
ChanID: msg.GetChannel(),
|
|
}
|
|
thid, err := as.things.CanAccess(ctx, ar)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
msg.Publisher = thid.GetValue()
|
|
|
|
return as.pub.Publish(ctx, token, msg)
|
|
}
|