Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/bigbasket/go-web-middleware

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/bigbasket/go-web-middleware

  • v0.0.0-20201118131902-c80c4739def0
  • Source
  • Go
  • Socket score

Version published
Created
Source

go-web-middleware

Import Package

    go get github.com/BigBasket/go-web-middleware

The Objective of this package is to manage common middlewares needed for golang web applications.

JWT-RSA

web apis that are using rsa-jwt token for security can instrument the middleware to parse and validate the token.

import (
    "github.com/BigBasket/go-web-middleware/auth/jwt"
    "github.com/gorilla/mux"
    "github.com/lestrrat-go/jwx/jwa"
)

func testHandler (w http.ResponseWriter, r *http.Request) {
    w.Write(http.StatusOK)
}

func main() {
    router := mux.NewRouter()
    jwtDecode := &RSADecode{
        PublicKey : "key" // base64 encoded rsa public key
        Algorithm: jwa.RS256
    }
    router.Use(jwtDecode.InstrumentJWTBearerToken)
    router.HandleFunc("/order/1", testHandler).Methods(http.MethodGet)
}

NewRelic

import (
    "github.com/BigBasket/go-web-middleware/profiling/newrelic"
    log "github.com/sirupsen/logrus"
)

func testHandler (w http.ResponseWriter, r *http.Request) {
    tx := newrelic.FetchTransaction(r.Context())
    // use the newrelic transaction for creating segments etc..
    w.Write(http.StatusOK)
}

func main() {
    router := mux.NewRouter()
    nConn, err := NewConnection(ctx, ConnectionConfig{
		newrelic.Config{AppName: "newrelic-test",
			License: "testkey"},
	})
	if err != nil {
        // handle errors
		return
    }
    router.Use(nConn.InstrumentNewRelic)
    router.HandleFunc("/order/1", testHandler).Methods(http.MethodGet)
}

XTracker

import (
    "github.com/BigBasket/go-web-middleware/profiling/tracker"
)

func testHandler (w http.ResponseWriter, r *http.Request) {
    tracker := FetchXTracker(r.Context())
    w.Write(http.StatusOK)
}

func main() {
    router := mux.NewRouter()
    router.Use(profiling.InstrumentXTracker)
    router.HandleFunc("/order/1", testHandler).Methods(http.MethodGet)
}

FAQs

Package last updated on 18 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc