main.go 875 B

123456789101112131415161718192021222324252627282930
  1. // Code generated by hertz generator.
  2. package main
  3. import (
  4. "github.com/cloudwego/hertz/pkg/app/server"
  5. "github.com/hertz-contrib/cors"
  6. "pji_desktop_http/biz/dal"
  7. "pji_desktop_http/common/config"
  8. "pji_desktop_http/common/config/c_log"
  9. )
  10. func main() {
  11. dal.Init()
  12. c_log.InitLog("logs/", "desktop_http")
  13. config.InitOssConfig()
  14. //h := server.Default()
  15. h := server.New(
  16. server.WithStreamBody(true),
  17. )
  18. h.Use(cors.New(cors.Config{
  19. AllowOrigins: []string{"*"},
  20. AllowMethods: []string{"POST, GET, OPTIONS, PUT, DELETE, UPDATE"},
  21. AllowHeaders: []string{"Origin, X-Requested-With, Content-Type, Accept, Authorization"},
  22. ExposeHeaders: []string{"Content-Length, Content-Disposition, Access-Control-Allow-Origin, Access-Control-Allow-Headers, Cache-Control, Content-Language, Content-Type"},
  23. AllowCredentials: true,
  24. }))
  25. register(h)
  26. h.Spin()
  27. }