Skip to content

Commit

Permalink
add autocert func into easy-admin
Browse files Browse the repository at this point in the history
  • Loading branch information
xxl4 committed Nov 3, 2023
1 parent 1035b37 commit 78a3940
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
47 changes: 47 additions & 0 deletions cmd/autocert/server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package autocert

import (
"log"
"net/http"

"github.com/gin-gonic/autotls"
"github.com/gin-gonic/gin"
"github.com/spf13/cobra"
)

var (
configYml string
apiCheck bool
StartCmd = &cobra.Command{
Use: "autocert",
Short: "autocert let https",
Example: "easy-admin autocert -c config/settings.yml",
SilenceUsage: true,
PreRun: func(cmd *cobra.Command, args []string) {
setup()
},
RunE: func(cmd *cobra.Command, args []string) error {
return run()
},
}
)

func init() {

}

func setup() {

}

func run() error {
r := gin.Default()

// Ping handler
r.GET("/ping", func(c *gin.Context) {
c.String(http.StatusOK, "pong")
})

log.Fatal(autotls.Run(r, "example1.com", "example2.com"))
return nil
}
2 changes: 2 additions & 0 deletions cmd/cobra.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/nicelizhi/easy-admin-core/sdk/pkg"

"github.com/nicelizhi/easy-admin/cmd/app"
"github.com/nicelizhi/easy-admin/cmd/autocert"
"github.com/nicelizhi/easy-admin/common/global"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -45,6 +46,7 @@ func init() {
rootCmd.AddCommand(migrate.StartCmd)
rootCmd.AddCommand(version.StartCmd)
rootCmd.AddCommand(app.StartCmd)
rootCmd.AddCommand(autocert.StartCmd)
}

// Execute : apply commands
Expand Down

0 comments on commit 78a3940

Please sign in to comment.