diff --git a/go.mod b/go.mod index 34663af..eb84467 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,14 @@ module git.ailur.dev/ailur/datatracker go 1.23.3 require ( - git.ailur.dev/ailur/fg-library/v3 v3.5.0 - git.ailur.dev/ailur/fg-nucleus-library v1.1.0 + git.ailur.dev/ailur/fg-library/v3 v3.6.2 + git.ailur.dev/ailur/fg-nucleus-library v1.2.0 github.com/golang-jwt/jwt/v5 v5.2.1 github.com/google/uuid v1.6.0 ) require github.com/go-chi/chi/v5 v5.2.0 // indirect + +replace git.ailur.dev/ailur/fg-library/v3 => /home/liqing/Projects/libraries/fg-library/ + +replace git.ailur.dev/ailur/fg-nucleus-library => /home/liqing/Projects/libraries/auth-library/ diff --git a/go.sum b/go.sum index d6b0156..a39f116 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,9 @@ git.ailur.dev/ailur/fg-library/v3 v3.5.0 h1:BGDlS4nQ2PyZWNU4gH3eckVqhZUFIM/zKIj/HXx8RmA= git.ailur.dev/ailur/fg-library/v3 v3.5.0/go.mod h1:ArNsafpqES2JuxQM5aM+bNe0FwHLIsL6pbjpiWvDwGs= +git.ailur.dev/ailur/fg-library/v3 v3.5.1 h1:9QH1myeXhGIlkihzYnH5jdgnD8UUStWC7aVWWq81hUU= +git.ailur.dev/ailur/fg-library/v3 v3.5.1/go.mod h1:ArNsafpqES2JuxQM5aM+bNe0FwHLIsL6pbjpiWvDwGs= +git.ailur.dev/ailur/fg-library/v3 v3.5.2 h1:rGvZSvmWPRMDGcM7ORMEAR2bd6QJx8vUKdki1SjRkoE= +git.ailur.dev/ailur/fg-library/v3 v3.5.2/go.mod h1:ArNsafpqES2JuxQM5aM+bNe0FwHLIsL6pbjpiWvDwGs= git.ailur.dev/ailur/fg-nucleus-library v1.0.5 h1:0YVSHFOeydGR/pfq5AfiKQ5gWuxSnx8u2K8mHvEDDTI= git.ailur.dev/ailur/fg-nucleus-library v1.0.5/go.mod h1:nKYjJ+zJD1YcrEGWlyyA5r6CrzW8DWHVAnL9hkn2tNw= git.ailur.dev/ailur/fg-nucleus-library v1.1.0 h1:D0eWwdlaw4IiOwz96MiRwHIdU/VIwiHUCeO00HkzzsU= diff --git a/main.go b/main.go index 23a60b0..f947b4a 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "errors" + "fmt" "time" "crypto/ed25519" @@ -34,12 +35,13 @@ var ( loggerService = uuid.MustParse("00000000-0000-0000-0000-000000000002") ) -func logFunc(message string, messageType library.MessageCode, information library.ServiceInitializationInformation) { +func logFunc(message string, messageType library.MessageCode, information *library.ServiceInitializationInformation) { // Log the message to the logger service + fmt.Println("here i am, sending a message to the logger service") information.SendISMessage(loggerService, messageType, message) } -func renderTemplate(statusCode int, w http.ResponseWriter, data map[string]interface{}, templatePath string, information library.ServiceInitializationInformation) { +func renderTemplate(statusCode int, w http.ResponseWriter, data map[string]interface{}, templatePath string, information *library.ServiceInitializationInformation) { var err error var requestedTemplate *template.Template // Output ls of the resource directory @@ -57,7 +59,7 @@ func renderTemplate(statusCode int, w http.ResponseWriter, data map[string]inter } } -func renderString(statusCode int, w http.ResponseWriter, data string, information library.ServiceInitializationInformation) { +func renderString(statusCode int, w http.ResponseWriter, data string, information *library.ServiceInitializationInformation) { w.WriteHeader(statusCode) _, err := w.Write([]byte(data)) if err != nil { @@ -65,7 +67,7 @@ func renderString(statusCode int, w http.ResponseWriter, data string, informatio } } -func renderJSON(statusCode int, w http.ResponseWriter, data map[string]interface{}, information library.ServiceInitializationInformation) { +func renderJSON(statusCode int, w http.ResponseWriter, data map[string]interface{}, information *library.ServiceInitializationInformation) { w.WriteHeader(statusCode) err := json.NewEncoder(w).Encode(data) if err != nil { @@ -162,11 +164,14 @@ func verifyJwt(token string, publicKey ed25519.PublicKey, conn library.Database) return claims, true } -func Main(information library.ServiceInitializationInformation) { +func Main(information *library.ServiceInitializationInformation) { var conn library.Database hostName := information.Configuration["hostName"].(string) + go information.StartISProcessor() + // Initiate a connection to the database + fmt.Println("Connecting to the database") conn, err := information.GetDatabase() if err != nil { logFunc(err.Error(), 3, information)