Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain structure for handling middleware This is base on alice. I think alice is good but whitout call(next(next(next))), I think this is not a good thing to have this kind of chain. also the ResponseWriter need more extra Data to handle
func NewChain ¶
func NewChain(f ...Middleware) Chain
NewChain create new middleware chain base on provided middlewares function
func (Chain) Extend ¶
func (mc Chain) Extend(f ...Middleware) Chain
Extend Append function to middleware chain and return NEW chain object The old chain is usable after this.
type Middleware ¶
Middleware is the call back used for middlewares
type ResponseWriter ¶
type ResponseWriter interface { // The original response writer http.ResponseWriter // Flusher interface http.Flusher // Hijacker is used in websocket connections and al upgrade request http.Hijacker //The status code set by the client Status() int // How many byte written into this writer Size() int // Is the output is written already or not? Written() bool // Get the current context Context() context.Context // Set the context with a value SetWithValue(key interface{}, value interface{}) // Set the context with timeout SetWithTimeout(time.Duration) context.CancelFunc // Set the context with deadline SetWithDeadline(time.Time) context.CancelFunc }
ResponseWriter is much like negroni ResponseWriter interface. But it also support context, using google context package, the context is readonly and can extend it with SetWith* functions
func NewResponseWriter ¶
func NewResponseWriter(rw http.ResponseWriter, ctx context.Context) ResponseWriter
NewResponseWriter Create new response writer base on http response writer interface TODO : do i need to implement hijacker and flusher interface?