太好了,我逐漸開始理解一切(並不)
This commit is contained in:
@@ -1,11 +1,16 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"Crimson-Gatekeeper/internal/application"
|
"net/http"
|
||||||
|
|
||||||
"github.com/go-spring/spring-core/gs"
|
"github.com/go-spring/spring-core/gs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Test struct{}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
gs.Provide(application.New).AsServer()
|
http.HandleFunc("/echo", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Write([]byte("hello world!"))
|
||||||
|
})
|
||||||
|
gs.Run()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,26 @@
|
|||||||
package application
|
package application
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/go-spring/spring-core/gs"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Controller interface {
|
type Controller interface {
|
||||||
RegisterRoute()
|
RegisterRoute()
|
||||||
}
|
}
|
||||||
|
|
||||||
func New() *gin.Engine {
|
type AppPak struct {
|
||||||
app := gin.Default()
|
core *gin.Engine
|
||||||
return app
|
}
|
||||||
|
|
||||||
|
func (s *AppPak) ListenAndServe(sig gs.ReadySignal) error {
|
||||||
|
s.core = gin.Default()
|
||||||
|
s.core.Run("7777")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (_ *AppPak) Shutdown(ctx context.Context) error {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user