xhttp

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: AGPL-3.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthIsBearer added in v0.3.8

func AuthIsBearer(authType string) bool

func ExtractAuthorizationInfo added in v0.3.8

func ExtractAuthorizationInfo(r *http.Request, header string) (authType string, authInfo string)

func ExtractTokenFromRequest

func ExtractTokenFromRequest(r *http.Request) (string, bool)

func JSONResponse

func JSONResponse(w http.ResponseWriter, closure func() (interface{}, error))

JSONResponse calls the closure and respond with data or error. If no error, but the interface is nil it will write "OK" to the response writer.

func WriteData

func WriteData(w http.ResponseWriter, data []byte)

func WriteJsonError

func WriteJsonError(w http.ResponseWriter, err error)

Types

type CertMaster added in v0.3.7

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

func NewCertMaster added in v0.3.7

func NewCertMaster(opts *CertMasterOpts) (*CertMaster, error)

func (*CertMaster) GetCertificate added in v0.3.7

func (m *CertMaster) GetCertificate(h *tls.ClientHelloInfo) (*tls.Certificate, error)

func (*CertMaster) Running added in v0.3.7

func (m *CertMaster) Running() bool

func (*CertMaster) Shutdown added in v0.3.7

func (m *CertMaster) Shutdown() error

type CertMasterOpts added in v0.3.7

type CertMasterOpts struct {
	Email        string
	CacheDir     string
	NonSSLRouter chi.Router
	Domains      []string
}

type DomainConfig

type DomainConfig struct {
	Mode        string   `yaml:"mode" valid:"required"`
	PrimaryName string   `yaml:"name" valid:"dns,required"`
	ExtraNames  []string `yaml:"extra_names,omitempty" valid:"dns"`
	IssueSSL    bool     `yaml:"issue_ssl,omitempty"`
	Schema      string   `yaml:"schema,omitempty"`
	Email       string   `yaml:"email,omitempty" valid:"email"`

	// Dir to store cached certificates, use sub-directory of cfgDir if possible.
	Dir string `yaml:"dir,omitempty" valid:"path"`
}

DomainConfig is the YAML version of the `adminAPI.DomainConfig` struct.

func (*DomainConfig) Validate

func (c *DomainConfig) Validate() error

type Issuer

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

Issuer should be named like certManager

func NewIssuer

func NewIssuer(opts *IssuerOpts) (*Issuer, error)

func (*Issuer) GetCertificate added in v0.3.7

func (is *Issuer) GetCertificate(domain string) *tls.Certificate

func (*Issuer) Shutdown added in v0.3.7

func (is *Issuer) Shutdown()

type IssuerOpts

type IssuerOpts struct {
	Domain       string
	CacheDir     string
	Email        string
	NonSSLRouter chi.Router
}

type Middleware

type Middleware = func(http.Handler) http.Handler

type Option

type Option func(w *Server)

func WithCORS

func WithCORS() Option

func WithDisableHTTPv2 added in v0.3.8

func WithDisableHTTPv2() Option

func WithLogger

func WithLogger() Option

func WithMetrics

func WithMetrics() Option

func WithMiddleware

func WithMiddleware(mw Middleware) Option

func WithSSL

func WithSSL(cfg *tls.Config) Option

type SSLConfig

type SSLConfig struct {
	// ListenAddr for HTTPS server, default: ":443"
	ListenAddr string `yaml:"listen_addr" valid:"listen_addr,required"`
}

type Server

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

func New

func New(opts ...Option) *Server

func NewDefault

func NewDefault() *Server

func NewDefaultSSL

func NewDefaultSSL(cfg *tls.Config) *Server

func NewRedirectToSSL

func NewRedirectToSSL(primaryHost string) *Server

func (*Server) Router

func (w *Server) Router() chi.Router

Router exposes chi.Router for the external registration of handlers. usage:

h.Router().Get("/apt/path", myHandler)
h.Router().Post("/apt/verb", myOtherHandler)

func (*Server) Run

func (w *Server) Run(addr string) error

Run starts the http server asynchronously.

func (*Server) Running

func (w *Server) Running() bool

func (*Server) Shutdown

func (w *Server) Shutdown() error

Jump to

Keyboard shortcuts

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