Skip to content

Commit

Permalink
Merge pull request #93 from TheThingsNetwork/feature/84-echo-middleware
Browse files Browse the repository at this point in the history
Add Echo HTTP Middleware
  • Loading branch information
bafonins authored Feb 4, 2019
2 parents 6d024ef + 6152026 commit d41a3e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/component/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/grpc-ecosystem/go-grpc-middleware"
"github.com/labstack/echo"
"github.com/labstack/echo/middleware"
"go.thethings.network/lorawan-stack/pkg/errors"
"go.thethings.network/lorawan-stack/pkg/rpcmiddleware/hooks"
"go.thethings.network/lorawan-stack/pkg/rpcmiddleware/rpclog"
Expand Down Expand Up @@ -52,7 +53,7 @@ func (c *Component) setupGRPC() (err error) {
for _, sub := range c.grpcSubsystems {
sub.RegisterHandlers(c.grpc.ServeMux, c.loopback)
}
c.web.RootGroup(ttnpb.HTTPAPIPrefix).Any("/*", echo.WrapHandler(http.StripPrefix(ttnpb.HTTPAPIPrefix, c.grpc)))
c.web.RootGroup(ttnpb.HTTPAPIPrefix).Any("/*", echo.WrapHandler(http.StripPrefix(ttnpb.HTTPAPIPrefix, c.grpc)), middleware.CORS())
return nil
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"strings"

"github.com/labstack/echo"
echomiddleware "github.com/labstack/echo/middleware"
"go.thethings.network/lorawan-stack/pkg/config"
"go.thethings.network/lorawan-stack/pkg/errors"
"go.thethings.network/lorawan-stack/pkg/log"
Expand Down Expand Up @@ -77,6 +78,9 @@ func New(ctx context.Context, config config.HTTP) (*Server, error) {

server.Use(
middleware.ID(""),
echomiddleware.BodyLimit("16M"),
echomiddleware.Secure(),
echomiddleware.Recover(),
cookie.Cookies(blockKey, hashKey),
)

Expand Down

0 comments on commit d41a3e5

Please sign in to comment.