mirror of
https://github.com/bestnite/sub2sing-box.git
synced 2025-10-28 09:33:57 +00:00
feat: api server
This commit is contained in:
22
api/server.go
Normal file
22
api/server.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"sub2sing-box/api/handler"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func RunServer(port uint16) {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
r := gin.Default()
|
||||
|
||||
r.GET("/convert", handler.Convert)
|
||||
|
||||
fmt.Println("Server is running on port ", port)
|
||||
err := r.Run(":" + strconv.Itoa(int(port)))
|
||||
if err != nil {
|
||||
fmt.Println("Run server failed: ", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user