mirror of
https://github.com/mainflux/mainflux.git
synced 2025-05-02 22:17:10 +08:00

* Improve path parameters naming Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * Improve path parameter naming improve path parameter naming for: bootstrap/api/transport.go twins/api/http/transport.go Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * Change functions to suit updated path params Duplicated the functions decodeView and decodeListByConnection to form new functions decodeThingView, decodeChannelView, decodeThingListByConnection and decodeChannelListByConnection. This was as a result of the two functions being used for both view thing and view channel services Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * Improve path parameter naming Improve path parameter naming for: auth/api/http/groups/transport.go bootstrap/api/transport.go twins/api/http/transport.go ws/api/endpoints.go Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * fix swagger files Updated the following swagger files api/openapi/auth.yml api/openapi/cert.yml api/openapi/websocket.yml Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * Move websocket.yml from openapi to asyncapi deleted websocket.yml file in openapi and created websocket.yml file in asyncapi Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * Update websocket.yml file Update the websocket.yml file to make subtopic optional and added security (bearerAuth) Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * Format new line correctly format newline for api/asyncapi/websocket.yml Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * update websocket.yml file update the websocket.yml file based on the requested review changes The document is now valid Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * Update path parameter naming make changes to path parameter naming in: api/openapi/consumers-notifiers.yml Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * update path parameters naming Update path parameters naming to be consistent with Go Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * update the mqtt.yml file update the mqtt.yml file to the latest AsyncAPI version and make changes on the security of the server Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * Add contact information Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * Update api/asyncapi/mqtt.yml Co-authored-by: b1ackd0t <blackd0t@protonmail.com> Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> * Add an empty line between functions Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> --------- Signed-off-by: ianmuchyri <ianmuchiri8@gmail.com> Co-authored-by: b1ackd0t <blackd0t@protonmail.com> Co-authored-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
// Copyright (c) Mainflux
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package api
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
|
|
"github.com/go-zoo/bone"
|
|
"github.com/gorilla/websocket"
|
|
"github.com/mainflux/mainflux"
|
|
log "github.com/mainflux/mainflux/logger"
|
|
"github.com/mainflux/mainflux/ws"
|
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
|
)
|
|
|
|
const (
|
|
protocol = "ws"
|
|
readwriteBufferSize = 1024
|
|
)
|
|
|
|
var (
|
|
errUnauthorizedAccess = errors.New("missing or invalid credentials provided")
|
|
errMalformedSubtopic = errors.New("malformed subtopic")
|
|
)
|
|
|
|
var (
|
|
upgrader = websocket.Upgrader{
|
|
ReadBufferSize: readwriteBufferSize,
|
|
WriteBufferSize: readwriteBufferSize,
|
|
CheckOrigin: func(r *http.Request) bool { return true },
|
|
}
|
|
logger log.Logger
|
|
)
|
|
|
|
// MakeHandler returns http handler with handshake endpoint.
|
|
func MakeHandler(svc ws.Service, l log.Logger) http.Handler {
|
|
logger = l
|
|
|
|
mux := bone.New()
|
|
mux.GetFunc("/channels/:chanID/messages", handshake(svc))
|
|
mux.GetFunc("/channels/:chanID/messages/*", handshake(svc))
|
|
mux.GetFunc("/version", mainflux.Health(protocol))
|
|
mux.Handle("/metrics", promhttp.Handler())
|
|
|
|
return mux
|
|
}
|