packageserverimport("github.com/go-kratos/kratos/v2/middleware/auth/jwt""github.com/go-kratos/kratos/v2/middleware/recovery""github.com/go-kratos/kratos/v2/middleware/tracing""github.com/go-kratos/kratos/v2/transport/http"jwtv4"github.com/golang-jwt/jwt/v4""gokratos-base/api/service/demo""gokratos-base/app/service/demo/internal/conf""gokratos-base/app/service/demo/internal/service""gokratos-base/common/httpext""time")// NewHTTPServer new a http server.funcNewHTTPServer(c*conf.Server,svc*service.DemoService)*http.Server{varopts=[]http.ServerOption{http.Middleware(recovery.Recovery(),tracing.Server(),jwt.Server(func(token*jwtv4.Token)(interface{},error){return[]byte("testkey"),nil}),ValidateParams(),),http.ResponseEncoder(httpext.Encoder),http.ErrorEncoder(httpext.ErrorEncoder),}ifc.Http.Addr!=""{opts=append(opts,http.Address(c.Http.Addr))}ifc.Http.Timeout!=0{opts=append(opts,http.Timeout(time.Duration(c.Grpc.Timeout)*time.Second))}srv:=http.NewServer(opts...)demo.RegisterDemoHTTPServer(srv,svc)returnsrv}