server

package
v0.0.0-...-aa6ac0e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WhoisKey    contextKey = "whois"
	RemoteIPKey contextKey = "remoteIP"
)
View Source
const PeerCapName = "github.com/josh/datajar-server"

Variables

View Source
var MetricsRegistry = prometheus.NewRegistry()
View Source
var ReadsTotal = promauto.With(MetricsRegistry).NewCounterVec(
	prometheus.CounterOpts{
		Name: "datajar_reads_total",
		Help: "Tracks the number of Data Jar reads.",
	}, []string{"hostname", "ip", "path"},
)
View Source
var UnauthorizedTotal = promauto.With(MetricsRegistry).NewCounterVec(
	prometheus.CounterOpts{
		Name: "datajar_unauthorized_total",
		Help: "Tracks the number of unauthorized Data Jar requests.",
	}, []string{"hostname", "ip", "path"},
)
View Source
var WritesTotal = promauto.With(MetricsRegistry).NewCounterVec(
	prometheus.CounterOpts{
		Name: "datajar_writes_total",
		Help: "Tracks the number of Data Jar writes.",
	}, []string{"hostname", "ip", "path"},
)

Functions

func CanAccessPath

func CanAccessPath(requestPath string, caps []Capabilities, accessType string) bool

func CheckRequestPermissions

func CheckRequestPermissions(localClient *tailscale.LocalClient, r *http.Request, accessType string) (*apitype.WhoIsResponse, string, error)

func CheckRequestPermissionsHandler

func CheckRequestPermissionsHandler(localClient *tailscale.LocalClient, accessType string, handler http.Handler) http.Handler

func GetValueByPath

func GetValueByPath(store map[string]interface{}, requestPath string) (interface{}, error)

Given a HTTP request path, traverse the store and return the value at that path.

Types

type ACLMiddleware

type ACLMiddleware struct {
	// contains filtered or unexported fields
}

func (*ACLMiddleware) ServeHTTP

func (m *ACLMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Capabilities

type Capabilities struct {
	Read    []string `json:"read"`
	Write   []string `json:"write"`
	Metrics bool     `json:"metrics"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL