http

package
v1.70.3 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2025 License: MIT Imports: 28 Imported by: 6

Documentation

Overview

Package http provides common functionality for http servers

Index

Constants

This section is empty.

Variables

View Source
var Command = &cobra.Command{
	Use:   "http remote:path",
	Short: `Serve the remote over HTTP.`,
	Long: `Run a basic web server to serve a remote over HTTP.
This can be viewed in a web browser or you can make a remote of type
http read from it.

You can use the filter flags (e.g. ` + "`--include`, `--exclude`" + `) to control what
is served.

The server will log errors.  Use ` + "`-v`" + ` to see access logs.

` + "`--bwlimit`" + ` will be respected for file transfers.  Use ` + "`--stats`" + ` to
control the stats printing.

` + libhttp.Help(flagPrefix) + libhttp.TemplateHelp(flagPrefix) + libhttp.AuthHelp(flagPrefix) + vfs.Help() + proxy.Help,
	Annotations: map[string]string{
		"versionIntroduced": "v1.39",
		"groups":            "Filter",
	},
	Run: func(command *cobra.Command, args []string) {
		var f fs.Fs
		if proxy.Opt.AuthProxy == "" {
			cmd.CheckArgs(1, 1, command, args)
			f = cmd.NewFsSrc(args)
		} else {
			cmd.CheckArgs(0, 0, command, args)
		}

		cmd.Run(false, true, command, func() error {
			s, err := newServer(context.Background(), f, &Opt, &vfscommon.Opt, &proxy.Opt)
			if err != nil {
				fs.Fatal(nil, fmt.Sprint(err))
			}
			defer systemd.Notify()()
			return s.Serve()
		})
	},
}

Command definition for cobra

View Source
var DefaultOpt = Options{
	Auth:     libhttp.DefaultAuthCfg(),
	HTTP:     libhttp.DefaultCfg(),
	Template: libhttp.DefaultTemplateCfg(),
}

DefaultOpt is the default values used for Options

Opt is options set by command line flags

OptionsInfo describes the Options in use

Functions

This section is empty.

Types

type HTTP added in v1.62.0

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

HTTP contains everything to run the server

func (*HTTP) Addr added in v1.70.0

func (s *HTTP) Addr() net.Addr

Addr returns the first address of the server

func (*HTTP) Serve added in v1.70.0

func (s *HTTP) Serve() error

Serve HTTP until the server is shutdown

func (*HTTP) Shutdown added in v1.70.0

func (s *HTTP) Shutdown() error

Shutdown the server

type Options added in v1.56.0

type Options struct {
	Auth     libhttp.AuthConfig
	HTTP     libhttp.Config
	Template libhttp.TemplateConfig
}

Options required for http server

Jump to

Keyboard shortcuts

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