httpservice

package
v0.0.0-...-02218b7 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2015 License: LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

The httpservice package provides a way to run a simple HTTP server service as a charm. It does not provide any way to interact with the running service - for more control, see the httprelation and service packages, which the httpservice package uses for its implementation.

Index

Constants

This section is empty.

Variables

View Source
var ErrHTTPSNotConfigured = errgo.New("HTTPS not configured")

Functions

This section is empty.

Types

type Service

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

Service represents an HTTP service. It provides an http relation runs a Go HTTP handler as a service.

func (*Service) HTTPPort

func (svc *Service) HTTPPort() int

HTTPPort returns the currently configured HTTP port for the service.

func (*Service) HTTPSPort

func (svc *Service) HTTPSPort() int

HTTPSPort returns the currently configured HTTPS port for the service.

func (*Service) PublicHTTPSURL

func (svc *Service) PublicHTTPSURL() (string, error)

PublicHTTPSURL returns an http URL that can be used to access the HTTPS service, not including the trailing slash. It returns ErrHTTPSNotConfigured if there is no current https service.

func (*Service) PublicHTTPURL

func (svc *Service) PublicHTTPURL() (string, error)

PublicHTTPURL returns a URL that can be used to access the HTTP service, not including the trailing slash. TODO https?

func (*Service) Register

func (svc *Service) Register(r *hook.Registry, serviceName, relationName string, handler interface{})

Register registers the service with the given registry. If serviceName is non-empty, it specifies the name of the service, otherwise the service will be named after the charm's unit. The relationName parameter specifies the name of the http relation.

The handler value must be a function of the form:

func(T) (http.Handler, error)

for some type T that can be marshaled as JSON. When the service is started, this function will be called with the arguments provided to the Start method.

Note that the handler function will not be called with any hook context available, as it is run by the OS-provided service runner (e.g. upstart).

func (*Service) Restart

func (svc *Service) Restart() error

Restart restarts the service.

func (*Service) Start

func (svc *Service) Start(arg interface{}) error

Start starts the service with the given argument. The type of arg must be the same as the type T in the handler function provided to Register.

If the argument values change, the service will be be restarted, otherwise the service will be left unchanged if it is already started.

func (*Service) Stop

func (svc *Service) Stop() error

Stop stops the service.

Jump to

Keyboard shortcuts

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