apiserver

package
v0.0.0-...-47020db Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Apiserver

type Apiserver struct {
	Logger        logging.Logger
	Router        *mux.Router
	MongoDatabase *mongo.Database
}

func New

func New(config *Config) *Apiserver

New creates and configures new apiserver

func (*Apiserver) ServeHTTP

func (as *Apiserver) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Apiserver) Start

func (as *Apiserver) Start(config *Config) error

Start creates net listener and starts the apiserver

type Config

type Config struct {
	BindAddr      string         `yaml:"bind_addr" json:"bind_addr"`
	BindPort      uint16         `yaml:"bind_port" json:"bind_port"`
	LogLevel      string         `yaml:"log_level" json:"log_level"`
	MongoDB       *MongoDBConfig `yaml:"mongodb"`
	APIPrefix     string         `yaml:"api_prefix" json:"api_prefix"`
	BlackListURLs []string       `yaml:"blacklist_urls" json:"blacklist_urls"`
}

func NewConfig

func NewConfig() *Config

NewConfig creates New config and populates it with default values BindAddr: "0.0.0.0" BindPort: 8080 LogLevel: info

func (*Config) FromYAML

func (c *Config) FromYAML(path string) error

type MongoDBConfig

type MongoDBConfig struct {
	Host         string        `yaml:"host" json:"host"`
	Port         uint16        `yaml:"port" json:"port"`
	Database     string        `yaml:"database" json:"database"`
	AuthDB       string        `yaml:"auth_db" json:"auth_db"`
	Collection   string        `yaml:"collection" json:"collection"`
	UsernameFile string        `yaml:"username_file" json:"username_file"`
	PasswordFile string        `yaml:"password_file" json:"password_file"`
	Username     string        `yaml:"username"`
	Password     string        `yaml:"password"`
	LinkTTL      time.Duration `yaml:"link_ttl" json:"link_ttl"`
}

func NewMongoDBConfig

func NewMongoDBConfig() *MongoDBConfig

Jump to

Keyboard shortcuts

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