-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathendpoint_mapping.go
More file actions
33 lines (28 loc) · 959 Bytes
/
endpoint_mapping.go
File metadata and controls
33 lines (28 loc) · 959 Bytes
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
package reverseproxy
import (
"context"
"net/http"
)
// CompositeResponse represents a transformed response from multiple backend requests
type CompositeResponse struct {
StatusCode int
Headers http.Header
Body []byte
}
// BackendEndpointRequest defines a request to be sent to a backend
type BackendEndpointRequest struct {
Backend string
Method string
Path string
Headers map[string]string
QueryParams map[string]string
}
// EndpointMapping defines how requests should be routed to different backends
// and how their responses should be combined
type EndpointMapping struct {
// Endpoints lists the backend requests to make
Endpoints []BackendEndpointRequest
// ResponseTransformer is a function that transforms multiple backend responses
// into a single composite response
ResponseTransformer func(ctx context.Context, req *http.Request, responses map[string]*http.Response) (*CompositeResponse, error)
}