This commit is contained in:
parent
a48d1238a2
commit
940f6ea1b5
@ -73,6 +73,10 @@ func main() {
|
|||||||
LogLevel: log.ERROR,
|
LogLevel: log.ERROR,
|
||||||
}))
|
}))
|
||||||
app.Use(middleware.Secure())
|
app.Use(middleware.Secure())
|
||||||
|
app.Use(middleware.CORSWithConfig(middleware.CORSConfig{
|
||||||
|
AllowOrigins: []string{"*"},
|
||||||
|
AllowHeaders: []string{echo.HeaderOrigin, echo.HeaderContentType, echo.HeaderAccept, echo.HeaderAuthorization},
|
||||||
|
}))
|
||||||
|
|
||||||
app.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
|
app.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
|
||||||
Format: "${time_custom} ${method} ${uri} ---> ${status} in ${latency_human} (${bytes_out} bytes)\n",
|
Format: "${time_custom} ${method} ${uri} ---> ${status} in ${latency_human} (${bytes_out} bytes)\n",
|
||||||
@ -213,7 +217,8 @@ func main() {
|
|||||||
|
|
||||||
func authed(next echo.HandlerFunc) echo.HandlerFunc {
|
func authed(next echo.HandlerFunc) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
if c.Request().Header.Get("Authorization") != token {
|
provided := c.Request().Header.Get("Authorization")
|
||||||
|
if provided != fmt.Sprintf("Bearer %s", token) {
|
||||||
return c.NoContent(http.StatusUnauthorized)
|
return c.NoContent(http.StatusUnauthorized)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user