-
Notifications
You must be signed in to change notification settings - Fork 18
/
rest.go
38 lines (31 loc) · 1.25 KB
/
rest.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 rest
import (
"net/http"
"github.com/canonical/lxd/lxd/response"
"github.com/canonical/microcluster/state"
)
// EndpointAlias represents an alias URL of and Endpoint in our API.
type EndpointAlias struct {
Name string // Name for this alias.
Path string // Path pattern for this alias.
}
// EndpointAction represents an action on an API endpoint.
type EndpointAction struct {
Handler func(state *state.State, r *http.Request) response.Response
AccessHandler func(state *state.State, r *http.Request) response.Response
AllowUntrusted bool
ProxyTarget bool // Allow forwarding of the request to a target if ?target=name is specified.
}
// Endpoint represents a URL in our API.
type Endpoint struct {
Name string // Name for this endpoint.
Path string // Path pattern for this endpoint.
Aliases []EndpointAlias // Any aliases for this endpoint.
Get EndpointAction
Put EndpointAction
Post EndpointAction
Delete EndpointAction
Patch EndpointAction
AllowedDuringShutdown bool // Whether we should return Unavailable Error (503) if daemon is shutting down.
AllowedBeforeInit bool // Whether we should return Unavailabel Error (503) if the daemon has not been initialized (is not yet part of a cluster).
}