domainmux

package module
v1.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

README

domainmux

Domain Mux allows to serve multiple domains and subdomains with different logics, compatible with the standard library and frameworks (like gin and echo)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsLocalhost

func IsLocalhost(remoteAddr string) bool

func SplitAddrPort

func SplitAddrPort(host string) string

func SplitDomainSubdomain

func SplitDomainSubdomain(host string) (domain string, subdomain string)

Types

type Context

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

func (*Context) DomainMux

func (ctx *Context) DomainMux() *DomainMux

func (*Context) HasParam

func (ctx *Context) HasParam(key string) bool

func (*Context) HasValue

func (ctx *Context) HasValue(key string) bool

func (*Context) Host

func (ctx *Context) Host() string

func (*Context) IsServeCalled

func (ctx *Context) IsServeCalled() bool

func (*Context) Next

func (ctx *Context) Next(w http.ResponseWriter, r *http.Request)

func (*Context) Param

func (ctx *Context) Param(key string) string

func (*Context) Path

func (ctx *Context) Path() []string

func (*Context) Redirect

func (ctx *Context) Redirect(host string, rerun bool)

func (*Context) SetServeCalled

func (ctx *Context) SetServeCalled()

func (*Context) SetValue

func (ctx *Context) SetValue(key, value string)

func (*Context) Value

func (ctx *Context) Value(key string) string

type DomainMux

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

func NewDomainMux

func NewDomainMux() *DomainMux

func (*DomainMux) Middleware

func (dm *DomainMux) Middleware(pattern string, middlewares ...Handler)

func (*DomainMux) RedirectIfLocal

func (dm *DomainMux) RedirectIfLocal(isLocal func(remoteAddr string) bool, rerun bool, middleware HandlerFunc) Handler

func (*DomainMux) Serve

func (dm *DomainMux) Serve(pattern string, handler Handler)

func (*DomainMux) ServeHTTP

func (dm *DomainMux) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*DomainMux) String

func (dm *DomainMux) String() string

type Handler

type Handler interface {
	ServeDomainMux(ctx *Context, w http.ResponseWriter, r *http.Request)
}

func StandardHandler

func StandardHandler(h http.Handler) Handler

type HandlerFunc

type HandlerFunc func(ctx *Context, w http.ResponseWriter, r *http.Request)

func StandardHandlerFunc

func StandardHandlerFunc(f http.HandlerFunc) HandlerFunc

func (HandlerFunc) ServeDomainMux

func (f HandlerFunc) ServeDomainMux(ctx *Context, w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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