Skip to content

Commit

Permalink
Removed support for context aware handlers (rs#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikegleasonjr authored and rs committed May 29, 2017
1 parent 2d7dd2a commit bf64c53
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 50 deletions.
26 changes: 0 additions & 26 deletions cors.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ import (
"os"
"strconv"
"strings"

"github.com/rs/xhandler"
"golang.org/x/net/context"
)

// Options is a configuration container to setup the CORS middleware.
Expand Down Expand Up @@ -192,29 +189,6 @@ func (c *Cors) Handler(h http.Handler) http.Handler {
})
}

// HandlerC is net/context aware handler
func (c *Cors) HandlerC(h xhandler.HandlerC) xhandler.HandlerC {
return xhandler.HandlerFuncC(func(ctx context.Context, w http.ResponseWriter, r *http.Request) {
if r.Method == "OPTIONS" {
c.logf("Handler: Preflight request")
c.handlePreflight(w, r)
// Preflight requests are standalone and should stop the chain as some other
// middleware may not handle OPTIONS requests correctly. One typical example
// is authentication middleware ; OPTIONS requests won't carry authentication
// headers (see #1)
if c.optionPassthrough {
h.ServeHTTPC(ctx, w, r)
} else {
w.WriteHeader(http.StatusOK)
}
} else {
c.logf("Handler: Actual request")
c.handleActualRequest(w, r)
h.ServeHTTPC(ctx, w, r)
}
})
}

// HandlerFunc provides Martini compatible handler
func (c *Cors) HandlerFunc(w http.ResponseWriter, r *http.Request) {
if r.Method == "OPTIONS" {
Expand Down
24 changes: 0 additions & 24 deletions examples/xhandler/server.go

This file was deleted.

0 comments on commit bf64c53

Please sign in to comment.