Documentation ¶
Overview ¶
Package http provides a registration interface for http services
Index ¶
- Variables
- func AddFlags(flagSet *pflag.FlagSet)
- func AddFlagsPrefix(flagSet *pflag.FlagSet, prefix string, Opt *Options)
- func Mount(pattern string, h http.Handler) error
- func Restart() error
- func Route(pattern string, fn func(r chi.Router)) (chi.Router, error)
- func Router() (chi.Router, error)
- func SetOptions(opt Options)
- func Shutdown() error
- func URL() string
- func Wait()
- type Middleware
- type Options
- type Server
Constants ¶
This section is empty.
Variables ¶
var DefaultOpt = Options{ ListenAddr: "127.0.0.1:8080", ServerReadTimeout: 1 * time.Hour, ServerWriteTimeout: 1 * time.Hour, MaxHeaderBytes: 4096, }
DefaultOpt is the default values used for Options
var Help = `
### Server options
Use ` + "`--addr`" + ` to specify which IP address and port the server should
listen on, eg ` + "`--addr 1.2.3.4:8000` or `--addr :8080`" + ` to listen to all
IPs. By default it only listens on localhost. You can use port
:0 to let the OS choose an available port.
If you set ` + "`--addr`" + ` to listen on a public or LAN accessible IP address
then using Authentication is advised - see the next section for info.
` + "`--server-read-timeout` and `--server-write-timeout`" + ` can be used to
control the timeouts on the server. Note that this is the total time
for a transfer.
` + "`--max-header-bytes`" + ` controls the maximum number of bytes the server will
accept in the HTTP header.
` + "`--baseurl`" + ` controls the URL prefix that rclone serves from. By default
rclone will serve from the root. If you used ` + "`--baseurl \"/rclone\"`" + ` then
rclone would serve from a URL starting with "/rclone/". This is
useful if you wish to proxy rclone serve. Rclone automatically
inserts leading and trailing "/" on ` + "`--baseurl`" + `, so ` + "`--baseurl \"rclone\"`" + `,
` + "`--baseurl \"/rclone\"` and `--baseurl \"/rclone/\"`" + ` are all treated
identically.
#### SSL/TLS
By default this will serve over http. If you want you can serve over
https. You will need to supply the ` + "`--cert` and `--key`" + ` flags.
If you wish to do client side certificate validation then you will need to
supply ` + "`--client-ca`" + ` also.
` + "`--cert`" + ` should be a either a PEM encoded certificate or a concatenation
of that with the CA certificate. ` + "`--key`" + ` should be the PEM encoded
private key and ` + "`--client-ca`" + ` should be the PEM encoded client
certificate authority certificate.
`
Help contains text describing the http server to add to the command help.
Functions ¶
func AddFlagsPrefix ¶
AddFlagsPrefix adds flags for the httplib
func Restart ¶
func Restart() error
Restart or start the default http server using the default options and no handlers
func SetOptions ¶
func SetOptions(opt Options)
SetOptions thread safe setter for the default server options
Types ¶
type Middleware ¶
Middleware function signature required by chi.Router.Use()
type Options ¶
type Options struct { ListenAddr string // Port to listen on BaseURL string // prefix to strip from URLs ServerReadTimeout time.Duration // Timeout for server reading data ServerWriteTimeout time.Duration // Timeout for server writing data MaxHeaderBytes int // Maximum size of request header SslCert string // Path to SSL PEM key (concatenation of certificate and CA certificate) SslKey string // Path to SSL PEM Private key SslCertBody []byte // SSL PEM key (concatenation of certificate and CA certificate) body, ignores SslCert SslKeyBody []byte // SSL PEM Private key body, ignores SslKey ClientCA string // Client certificate authority to verify clients with }
Options contains options for the http Server
func GetOptions ¶
func GetOptions() Options
GetOptions thread safe getter for the default server options
type Server ¶
type Server interface { Router() chi.Router Route(pattern string, fn func(r chi.Router)) chi.Router Mount(pattern string, h http.Handler) Shutdown() error }
Server interface of http server
func NewServer ¶
NewServer instantiates a new http server using provided listeners and options This function is provided if the default http server does not meet a services requirements and should not generally be used A http server can listen using multiple listeners. For example, a listener for port 80, and a listener for port 443. tlsListeners are ignored if opt.SslKey is not provided