feat: api structure

This commit is contained in:
Leandro Antônio Farias Machado 2023-04-20 11:34:48 -03:00
parent 83c88e87be
commit 0ff00b9ca1

View File

@ -5,6 +5,7 @@ package main
import ( import (
"context" "context"
"flag" "flag"
"github.com/leandrofars/oktopus/internal/api"
"github.com/leandrofars/oktopus/internal/db" "github.com/leandrofars/oktopus/internal/db"
"log" "log"
"os" "os"
@ -37,6 +38,7 @@ func main() {
flBrokerClientId := flag.String("i", "", "A clientid for the Mqtt connection") flBrokerClientId := flag.String("i", "", "A clientid for the Mqtt connection")
flBrokerQos := flag.Int("q", 2, "Quality of service of mqtt messages delivery") flBrokerQos := flag.Int("q", 2, "Quality of service of mqtt messages delivery")
flAddrDB := flag.String("mongo", "mongodb://localhost:27017/", "MongoDB URI") flAddrDB := flag.String("mongo", "mongodb://localhost:27017/", "MongoDB URI")
flApiPort := flag.String("ap", "8000", "Rest api port")
flHelp := flag.Bool("help", false, "Help") flHelp := flag.Bool("help", false, "Help")
flag.Parse() flag.Parse()
@ -69,6 +71,8 @@ func main() {
} }
mtp.MtpService(&mqttClient, done) mtp.MtpService(&mqttClient, done)
a := api.NewApi(*flApiPort, database)
api.StartApi(a)
<-done <-done
cancel() cancel()