server

package
Version: v0.0.0-...-506b656 Latest Latest
Warning

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

Go to latest
Published: May 16, 2017 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "oscanner",
	Short: "`oscanner`",
	Long:  "`oscanner`",
	Run: func(cmd *cobra.Command, args []string) {
		if showVersion {
			fmt.Printf("%v\n", version.Get())
			return
		}
		cmd.Usage()
	},
}

RootCmd is the main command for the 'registry' binary.

View Source
var ServeCmd = &cobra.Command{
	Use:   "serve <config>",
	Short: "`serve` serves requests to scan",
	Long:  "`serve` serves requests to scan.",
	Run: func(cmd *cobra.Command, args []string) {

		config, err := resolveConfiguration(args)
		if err != nil {
			fmt.Fprintf(os.Stderr, "configuration error: %v\n", err)
			cmd.Usage()
			os.Exit(1)
		}

		if err := configureLogging(config); err != nil {
			fmt.Fprintf(os.Stderr, "error configuring logger: %v", err)
			os.Exit(1)
		}

		if err := database.NewDB(config).Init(); err != nil {
			log.Fatalln(err)
		}

		uuid.Loggerf = log.Warnf

		in, err := instance.NewInstance(config)
		if err != nil {
			log.Fatalln(err)
		}

		registry, err := NewServer(in)
		if err != nil {
			log.Fatalln(err)
		}

		if err = registry.ListenAndServe(); err != nil {
			log.Fatalln(err)
		}
	},
}

ServeCmd is a cobra command for running the registry.

Functions

func NewHTTPHandler

func NewHTTPHandler(in *instance.Instance) http.Handler

Types

type HTTPHandler

type HTTPHandler struct {
	*instance.Instance
}

func (*HTTPHandler) ServeHTTP

func (o *HTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Server

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

A Server represents a complete instance of the oscanner.

func NewServer

func NewServer(in *instance.Instance) (*Server, error)

NewServer creates a new oscanner server.

func (*Server) ListenAndServe

func (srv *Server) ListenAndServe() error

ListenAndServe runs the registry's HTTP server.

Directories

Path Synopsis
api
v1

Jump to

Keyboard shortcuts

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