vhost

package module
v0.0.0-...-2e2d5ff Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

README

vhost

Simple couchdb database config based vhost handling

Getting started

handler = vhost.Middleware(gdb)

Database

Uses the _admin database for vhost configurations.

Every vhost needs a goydb.vhost: prefix. A vhost can have proxy configurations for reverse and db (database) proxing.

The vhost will be reacting to all specified domains.

Attachments can be used to serve static content at the root of the vhost.

{
    "_id": "goydb.vhost:example",
    "_attachments": {
        "app.zip": {
            "content_type": "application/x-zip-compressed",
            "revpos": 0,
            "digest": "21d318cbe5645a50257d1062d9dffb64",
            "length": 712001,
            "stub": true
        }
    },
    "_rev": "0-db20aa37f912a2d765a6197b0246b1e9",
    "domains": [
        "app.example.com",
        "app.example.internal"
    ],
    "proxy": {
        "/_session": {
            "target": "https://sessions.example.com/",
            "type": "reverse"
        },
        "/other": {
            "stripPrefix": true,
            "target": "https://other.example.com/dms/",
            "type": "reverse"
        },
        "/db": {
            "target": "appdb",
            "type": "db"
        }
    },
    "static": "app.zip"
}

Documentation

Index

Constants

View Source
const (
	VirtualHostDB     = "_admin"
	VirtualHostPrefix = "goydb.vhost:"
	VirtualHostFiles  = "files.zip"
)

Variables

This section is empty.

Functions

func Middleware

func Middleware(gdb goydb.Goydb) http.Handler

Middleware to handle virtual hosts

func NewProxyDBHandler

func NewProxyDBHandler(prefix, targetDB string, c *VirtualHost) http.Handler

Types

type VirtualHost

type VirtualHost struct {
	Storage port.Storage
	// contains filtered or unexported fields
}

VirtualHost Virtual host implements a http middleware. The middleware is configured using the vhost configration in the _admin database.

func (*VirtualHost) FindAllVHosts

func (c *VirtualHost) FindAllVHosts(ctx context.Context) ([]*model.VirtualHostConfiguration, error)

FindAllVHosts find all virtual host configurations in the database

func (*VirtualHost) Middleware

func (c *VirtualHost) Middleware() func(next http.Handler) http.Handler

func (*VirtualHost) RebuildHandler

func (c *VirtualHost) RebuildHandler() error

func (*VirtualHost) Run

func (c *VirtualHost) Run(ctx context.Context)

func (*VirtualHost) ServeHTTP

func (c *VirtualHost) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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