webserver

package
v0.0.0-...-4aac04f Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: BSD-2-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LOGIN_PATH     string = "/api/login"
	TEST_PATH      string = "/api/test"
	AUTH_TEST_PATH string = "/api/testauth"
	SHARD_PATH     string = "/api/shard/{custid}/{uuid}/{well}/{shardid}"
	CUST_PATH      string = "/api/shard/{custid}"
	INDEXER_PATH   string = "/api/shard/{custid}/{uuid}"
	WELL_PATH      string = "/api/shard/{custid}/{uuid}/{well}"
	TAG_PATH       string = "/api/tags/{custid}/{uuid}"
)

Variables

View Source
var (
	ErrInvalidChainArgs = errors.New("invalid base chain arguments")
	ErrVariableNotFound = errors.New("Variable not found in request")
)
View Source
var (
	ErrMissingJWTToken = errors.New("Missing JWT token")
)

Functions

This section is empty.

Types

type Authenticator

type Authenticator interface {
	Authenticate(custnum, passwd string) (cid uint64, err error)
}

type CustomerDetails

type CustomerDetails struct {
	CustomerNumber uint64
}

type HashHandler

type HashHandler struct {
	Hash []byte
}

mock handler for use in testing

func (*HashHandler) GetShardsInTimeframe

func (hh *HashHandler) GetShardsInTimeframe(cid uint64, guid uuid.UUID, well string, tf util.Timeframe) (shards []string, err error)

func (*HashHandler) GetTags

func (hh *HashHandler) GetTags(custid uint64, indexerUUID uuid.UUID) (tgs []tags.TagPair, err error)

func (*HashHandler) GetWellTimeframe

func (hh *HashHandler) GetWellTimeframe(cid uint64, guid uuid.UUID, well string) (t util.Timeframe, err error)

func (*HashHandler) ListIndexerWells

func (hh *HashHandler) ListIndexerWells(cid uint64, guid uuid.UUID) (r []string, err error)

func (*HashHandler) ListIndexes

func (hh *HashHandler) ListIndexes(cid uint64) (r []string, err error)

func (*HashHandler) PackShard

func (hh *HashHandler) PackShard(custid uint64, indexerUUID uuid.UUID, well string, shardID string, wtr io.Writer) error

func (*HashHandler) SyncTags

func (hh *HashHandler) SyncTags(custid uint64, indexerUUID uuid.UUID) (tgs []tags.TagPair, err error)

func (*HashHandler) UnpackShard

func (hh *HashHandler) UnpackShard(custid uint64, indexerUUID uuid.UUID, well string, shardID string, reader io.Reader) error

type LoginResponse

type LoginResponse struct {
	LoginStatus bool
	Reason      string
	JWT         string
}

type ShardHandler

type ShardHandler interface {
	UnpackShard(cid uint64, guid uuid.UUID, well, shard string, rdr io.Reader) error
	PackShard(cid uint64, guid uuid.UUID, well, shard string, wtr io.Writer) error
	ListIndexes(cid uint64) ([]string, error)
	ListIndexerWells(cid uint64, guid uuid.UUID) ([]string, error)
	GetWellTimeframe(cid uint64, guid uuid.UUID, well string) (util.Timeframe, error)
	GetShardsInTimeframe(cid uint64, guid uuid.UUID, well string, tf util.Timeframe) (shards []string, err error)
	GetTags(cid uint64, guid uuid.UUID) ([]tags.TagPair, error)
	SyncTags(cid uint64, guid uuid.UUID, idxTags []tags.TagPair) (tgs []tags.TagPair, err error)
}

type Webserver

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

func NewWebserver

func NewWebserver(conf WebserverConfig) (*Webserver, error)

func (*Webserver) AuthUser

func (w *Webserver) AuthUser(res http.ResponseWriter, req *http.Request) (cust *CustomerDetails)

AuthUser ensures the user is authenticated and allows the mux to continue

func (*Webserver) Close

func (w *Webserver) Close() error

func (*Webserver) Init

func (w *Webserver) Init() error

func (*Webserver) Run

func (w *Webserver) Run() error

type WebserverConfig

type WebserverConfig struct {
	ListenString string // addr:port
	DisableTLS   bool
	CertFile     string
	KeyFile      string
	Logger       *log.Logger
	ShardHandler ShardHandler
	Auth         Authenticator
}

Jump to

Keyboard shortcuts

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