No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

27 líneas
598 B

  1. package middleware
  2. import (
  3. "github.com/QuantumNous/new-api/common"
  4. "github.com/gin-contrib/cors"
  5. "github.com/gin-gonic/gin"
  6. )
  7. func CORS() gin.HandlerFunc {
  8. config := cors.DefaultConfig()
  9. config.AllowAllOrigins = false
  10. config.AllowOriginFunc = func(origin string) bool {
  11. return true
  12. }
  13. config.AllowCredentials = true
  14. config.AllowMethods = []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}
  15. config.AllowHeaders = []string{"*"}
  16. return cors.New(config)
  17. }
  18. func PoweredBy() gin.HandlerFunc {
  19. return func(c *gin.Context) {
  20. c.Header("X-New-Api-Version", common.Version)
  21. c.Next()
  22. }
  23. }