/
middlewares.go
38 lines (33 loc) · 899 Bytes
/
middlewares.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package requests
import (
"context"
"net/http"
)
// Middleware The interface definition of the middleware.
type Middleware interface {
//Go on.
Next()
Stop(...error)
// Returns the standard request object.
GetRequest() *http.Request
// Returns carry information for HTTP requests.
GetRespone() *Response
// Returns http package data.
GetResponeBody() []byte
IsStopped() bool
// Is HTTP/2 Cleartext Request.
IsH2C() bool
Context() context.Context
WithContextFromMiddleware(context.Context)
// Turn on link tracking for HTTP connections.
EnableTraceFromMiddleware()
// Set up client.
SetClientFromMiddleware(Client)
}
var middlewares []Handler
// Handler The definition of the middleware processor.
type Handler func(Middleware)
// InstallMiddleware Install the middleware processor.
func InstallMiddleware(handle ...Handler) {
middlewares = append(middlewares, handle...)
}