server.go 390 B

1234567891011121314151617181920212223242526272829
  1. package http
  2. import (
  3. "tmr-watch/http/routers"
  4. "github.com/gin-gonic/gin"
  5. )
  6. type Server struct {
  7. *gin.Engine
  8. }
  9. type Option func(*Server)
  10. func NewServer(options ...Option) *Server {
  11. s := &Server{
  12. Engine: gin.New(),
  13. }
  14. for _, option := range options {
  15. option(s)
  16. }
  17. return s
  18. }
  19. func SetRouteOption() Option {
  20. return func(s *Server) {
  21. routers.HTTPServerRoute()(s.Engine)
  22. }
  23. }