
All checks were successful
Build Quasar SPA and Go Backend for memberApp / build-spa (push) Successful in 2m12s
Build Quasar SPA and Go Backend for memberApp / build-backend (amd64, , linux) (push) Successful in 5m8s
Build Quasar SPA and Go Backend for memberApp / build-backend (amd64, .exe, windows) (push) Successful in 5m8s
Build Quasar SPA and Go Backend for memberApp / build-backend (arm, 6, , linux) (push) Successful in 4m57s
Build Quasar SPA and Go Backend for memberApp / build-backend (arm64, , linux) (push) Successful in 5m7s
39 lines
833 B
Go
39 lines
833 B
Go
package server
|
|
|
|
import (
|
|
"fmt"
|
|
"sync"
|
|
|
|
"gitea.tecamino.com/paadi/tecamino-dbm/cert"
|
|
"gitea.tecamino.com/paadi/tecamino-logger/logging"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// server model for database manager websocket
|
|
type Server struct {
|
|
Routes *gin.Engine
|
|
sync.RWMutex
|
|
Logger *logging.Logger
|
|
}
|
|
|
|
// initalizes new dbm server
|
|
func NewServer() *Server {
|
|
return &Server{
|
|
Routes: gin.Default(),
|
|
}
|
|
}
|
|
|
|
// serve dbm as http
|
|
func (s *Server) ServeHttp(ip string, port uint) error {
|
|
return s.Routes.Run(fmt.Sprintf("%s:%d", ip, port))
|
|
}
|
|
|
|
// serve dbm as http
|
|
func (s *Server) ServeHttps(url string, port uint, cert cert.Cert) error {
|
|
// generate self signed tls certificate
|
|
if err := cert.GenerateSelfSignedCert(); err != nil {
|
|
return err
|
|
}
|
|
return s.Routes.RunTLS(fmt.Sprintf("%s:%d", url, port), cert.CertFile, cert.KeyFile)
|
|
}
|