mirror of
https://github.com/mainflux/mainflux.git
synced 2025-04-26 13:48:53 +08:00
Gofmt
Signed-off-by: Drasko DRASKOVIC <drasko.draskovic@gmail.com>
This commit is contained in:
parent
c12a88d12f
commit
d38ea79dde
@ -1,21 +1,21 @@
|
||||
package clients
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
"log"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/mainflux/mainflux/config"
|
||||
"github.com/mainflux/mainflux/db"
|
||||
"github.com/mainflux/mainflux/models"
|
||||
"github.com/mainflux/mainflux/config"
|
||||
|
||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||
"github.com/krylovsk/gosenml"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||
)
|
||||
|
||||
type (
|
||||
@ -75,7 +75,6 @@ func (mqc *MqttConn) MqttSub(cfg config.Config) {
|
||||
WriteStatusChannel = make(chan ChannelWriteStatus)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* WriteChannel()
|
||||
* Generic function that updates the channel value.
|
||||
|
@ -34,7 +34,6 @@ type Config struct {
|
||||
InfluxDatabase string
|
||||
}
|
||||
|
||||
|
||||
func (cfg *Config) Parse() {
|
||||
|
||||
var confFile string
|
||||
|
@ -12,19 +12,19 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/mainflux/mainflux/clients"
|
||||
"github.com/mainflux/mainflux/db"
|
||||
"github.com/mainflux/mainflux/models"
|
||||
"github.com/mainflux/mainflux/clients"
|
||||
|
||||
"github.com/satori/go.uuid"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
|
||||
"io"
|
||||
"net/http"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-zoo/bone"
|
||||
)
|
||||
@ -127,7 +127,8 @@ func GetChannels(w http.ResponseWriter, r *http.Request) {
|
||||
// Set default limit to -5
|
||||
climit = -100
|
||||
} else {
|
||||
climit, err = strconv.Atoi(s); if err != nil {
|
||||
climit, err = strconv.Atoi(s)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
str := `{"response": "wrong count limit"}`
|
||||
io.WriteString(w, str)
|
||||
@ -140,7 +141,8 @@ func GetChannels(w http.ResponseWriter, r *http.Request) {
|
||||
// Set default limit to -5
|
||||
vlimit = -100
|
||||
} else {
|
||||
vlimit, err = strconv.Atoi(s); if err != nil {
|
||||
vlimit, err = strconv.Atoi(s)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
str := `{"response": "wrong value limit"}`
|
||||
io.WriteString(w, str)
|
||||
@ -177,7 +179,6 @@ func GetChannel(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
id := bone.GetValue(r, "channel_id")
|
||||
|
||||
|
||||
var vlimit int
|
||||
var err error
|
||||
s := r.URL.Query().Get("vlimit")
|
||||
@ -185,7 +186,8 @@ func GetChannel(w http.ResponseWriter, r *http.Request) {
|
||||
// Set default limit to -5
|
||||
vlimit = -5
|
||||
} else {
|
||||
vlimit, err = strconv.Atoi(s); if err != nil {
|
||||
vlimit, err = strconv.Atoi(s)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
str := `{"response": "wrong limit"}`
|
||||
io.WriteString(w, str)
|
||||
@ -204,7 +206,6 @@ func GetChannel(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
res, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
@ -255,7 +256,7 @@ func UpdateChannel(w http.ResponseWriter, r *http.Request) {
|
||||
// Publish the channel update.
|
||||
// This will be catched by the MQTT main client (subscribed to all channel topics)
|
||||
// and then written in the DB in the MQTT handler
|
||||
token := clients.MqttClient.Publish("mainflux/" + id, 0, false, string(data))
|
||||
token := clients.MqttClient.Publish("mainflux/"+id, 0, false, string(data))
|
||||
token.Wait()
|
||||
|
||||
// Wait on status from MQTT handler (which executes DB write)
|
||||
@ -290,5 +291,3 @@ func DeleteChannel(w http.ResponseWriter, r *http.Request) {
|
||||
str := `{"response": "deleted", "id": "` + id + `"}`
|
||||
io.WriteString(w, str)
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,8 +21,8 @@ import (
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
|
||||
"io"
|
||||
"net/http"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-zoo/bone"
|
||||
)
|
||||
@ -189,7 +189,6 @@ func UpdateDevice(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
Db := db.MgoDb{}
|
||||
Db.Init()
|
||||
defer Db.Close()
|
||||
|
12
main.go
12
main.go
@ -9,17 +9,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"strconv"
|
||||
"github.com/fatih/color"
|
||||
"github.com/mainflux/mainflux/clients"
|
||||
"github.com/mainflux/mainflux/config"
|
||||
"github.com/mainflux/mainflux/db"
|
||||
"github.com/mainflux/mainflux/servers"
|
||||
"github.com/mainflux/mainflux/clients"
|
||||
"github.com/fatih/color"
|
||||
"os"
|
||||
"runtime"
|
||||
"flag"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type MainfluxLite struct {
|
||||
|
@ -9,17 +9,15 @@
|
||||
package servers
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/mainflux/mainflux/controllers"
|
||||
"github.com/mainflux/mainflux/config"
|
||||
"github.com/mainflux/mainflux/controllers"
|
||||
|
||||
"github.com/go-zoo/bone"
|
||||
|
||||
)
|
||||
|
||||
|
||||
func HttpServer(cfg config.Config) {
|
||||
|
||||
mux := bone.New()
|
||||
@ -51,7 +49,7 @@ func HttpServer(cfg config.Config) {
|
||||
/**
|
||||
* Server
|
||||
*/
|
||||
http.ListenAndServe(cfg.HttpHost + ":" + strconv.Itoa(cfg.HttpPort), mux)
|
||||
http.ListenAndServe(cfg.HttpHost+":"+strconv.Itoa(cfg.HttpPort), mux)
|
||||
|
||||
// Use following to start HTTPS server on the same port
|
||||
//iris.ListenTLS(cfg.HttpHost + ":" + strconv.Itoa(cfg.HttpPort), "tls/mainflux.crt", "tls/mainflux.key")
|
||||
|
@ -9,12 +9,12 @@
|
||||
package servers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
"log"
|
||||
"os"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/mainflux/mainflux/config"
|
||||
"github.com/mainflux/mainflux/controllers"
|
||||
@ -24,7 +24,6 @@ import (
|
||||
"gopkg.in/mgo.v2"
|
||||
)
|
||||
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
// We are in testing - notify the program
|
||||
// so that it is not confused if some other commad line
|
||||
@ -75,7 +74,6 @@ func TestServer(t *testing.T) {
|
||||
var cfg config.Config
|
||||
cfg.Parse()
|
||||
|
||||
|
||||
// Create a request to pass to our handler. We don't have any query parameters for now, so we'll
|
||||
// pass 'nil' as the third parameter.
|
||||
req, err := http.NewRequest("GET", "/status", nil)
|
||||
@ -102,4 +100,3 @@ func TestServer(t *testing.T) {
|
||||
t.Errorf("handler returned unexpected body: got %v want %v", rr.Body.String(), expected)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user