2024-02-26 09:49:11 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-03-04 10:03:40 +01:00
|
|
|
"gibb165lb2/util"
|
2024-02-26 09:49:11 +01:00
|
|
|
"go.mongodb.org/mongo-driver/mongo"
|
|
|
|
"go.mongodb.org/mongo-driver/mongo/options"
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
|
|
defer cancel()
|
|
|
|
var err error
|
2024-03-04 10:19:35 +01:00
|
|
|
util.Client, err = mongo.Connect(ctx, options.Client().ApplyURI("mongodb://root:root12345@localhost:27017"))
|
2024-02-26 09:49:11 +01:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2024-03-04 10:19:35 +01:00
|
|
|
|
2024-03-04 10:03:40 +01:00
|
|
|
//util.InsertRandomData(client)
|
2024-03-04 10:19:35 +01:00
|
|
|
r := GetRouter()
|
2024-03-04 10:03:40 +01:00
|
|
|
|
2024-02-26 09:49:11 +01:00
|
|
|
err = http.ListenAndServe(":3333", r)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|