53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
package store
|
|
|
|
import (
|
|
"context"
|
|
"net/url"
|
|
)
|
|
|
|
type ProxyRepository interface {
|
|
CreateProxy(ctx context.Context, to *url.URL, from ...string) (*Proxy, error)
|
|
UpdateProxy(ctx context.Context, id ProxyID, funcs ...UpdateProxyOptionFunc) (*Proxy, error)
|
|
QueryProxies(ctx context.Context, funcs ...QueryProxyOptionFunc) ([]*ProxyHeader, error)
|
|
GetProxy(ctx context.Context, id ProxyID) (*Proxy, error)
|
|
DeleteProxy(ctx context.Context, id ProxyID) error
|
|
}
|
|
|
|
type UpdateProxyOptionFunc func(*UpdateProxyOptions)
|
|
|
|
type UpdateProxyOptions struct {
|
|
To *url.URL
|
|
From []string
|
|
}
|
|
|
|
func WithProxyUpdateTo(to *url.URL) UpdateProxyOptionFunc {
|
|
return func(o *UpdateProxyOptions) {
|
|
o.To = to
|
|
}
|
|
}
|
|
|
|
func WithProxyUpdateFrom(from ...string) UpdateProxyOptionFunc {
|
|
return func(o *UpdateProxyOptions) {
|
|
o.From = from
|
|
}
|
|
}
|
|
|
|
type QueryProxyOptionFunc func(*QueryProxyOptions)
|
|
|
|
type QueryProxyOptions struct {
|
|
To *url.URL
|
|
From []string
|
|
}
|
|
|
|
func WithProxyQueryTo(to *url.URL) QueryProxyOptionFunc {
|
|
return func(o *QueryProxyOptions) {
|
|
o.To = to
|
|
}
|
|
}
|
|
|
|
func WithProxyQueryFrom(from ...string) QueryProxyOptionFunc {
|
|
return func(o *QueryProxyOptions) {
|
|
o.From = from
|
|
}
|
|
}
|