Skip to content

Commit

Permalink
Merge pull request #2 from sarathsp06/patch-1
Browse files Browse the repository at this point in the history
Update gin.go so it uses constants
  • Loading branch information
err0r500 authored Mar 14, 2019
2 parents db92d73 + bccbc1b commit d752ac3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions infra/gin.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package infra

import (
"net/http"
"strconv"
"strings"
"time"

"github.com/gin-gonic/gin"
"github.com/itsjamie/gin-cors"
cors "github.com/itsjamie/gin-cors"
)

type GinServerMode int
Expand Down Expand Up @@ -49,7 +51,7 @@ func NewServer(port int, mode GinServerMode) GinServer {
func SetCors(engine *gin.Engine, allowedOrigins string) {
engine.Use(cors.Middleware(cors.Config{
Origins: allowedOrigins,
Methods: "GET, PUT, POST, DELETE, OPTION, PATCH",
Methods: strings.Join([]string{http.MethodGet, http.MethodPut, http.MethodPost, http.MethodOptions, http.MethodPatch}, ","),
RequestHeaders: "Origin, Authorization, Content-Type",
ExposedHeaders: "",
MaxAge: 50 * time.Second,
Expand Down

0 comments on commit d752ac3

Please sign in to comment.