Delete middlewares
Browse files- middlewares/auth.go +0 -31
- middlewares/cors.go +0 -10
middlewares/auth.go
DELETED
@@ -1,31 +0,0 @@
|
|
1 |
-
package middlewares
|
2 |
-
|
3 |
-
import (
|
4 |
-
"github.com/gin-gonic/gin"
|
5 |
-
"os"
|
6 |
-
"strings"
|
7 |
-
)
|
8 |
-
|
9 |
-
func Authorization(c *gin.Context) {
|
10 |
-
customer_key := os.Getenv("Authorization")
|
11 |
-
if customer_key != "" {
|
12 |
-
authHeader := c.GetHeader("Authorization")
|
13 |
-
if authHeader == "" {
|
14 |
-
c.JSON(401, gin.H{"error": "Unauthorized"})
|
15 |
-
c.Abort()
|
16 |
-
return
|
17 |
-
}
|
18 |
-
tokenParts := strings.Split(strings.Replace(authHeader, "Bearer ", "", 1)," ")
|
19 |
-
customAccessToken := tokenParts[0]
|
20 |
-
if customer_key != customAccessToken {
|
21 |
-
c.JSON(401, gin.H{"error": "Unauthorized"})
|
22 |
-
c.Abort()
|
23 |
-
return
|
24 |
-
}
|
25 |
-
if len(tokenParts) > 1 {
|
26 |
-
openaiAccessToken := tokenParts[1]
|
27 |
-
c.Request.Header.Set("Authorization", "Bearer " + openaiAccessToken)
|
28 |
-
}
|
29 |
-
}
|
30 |
-
c.Next()
|
31 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
middlewares/cors.go
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
package middlewares
|
2 |
-
|
3 |
-
import "github.com/gin-gonic/gin"
|
4 |
-
|
5 |
-
func Cors(c *gin.Context) {
|
6 |
-
c.Header("Access-Control-Allow-Origin", "*")
|
7 |
-
c.Header("Access-Control-Allow-Methods", "*")
|
8 |
-
c.Header("Access-Control-Allow-Headers", "*")
|
9 |
-
c.Next()
|
10 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|