transport

package
v0.0.0-...-1e04dac Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2018 License: GPL-3.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const (
	HSTS    = "max-age=63072000; preload"
	HSTSKey = "Strict-Transport-Security"

	XFrameDeny = "DENY"
	XFrameKey  = "X-Frame-Options"

	NoSniff  = "nosniff"
	XContent = "X-Content-Type-Options"

	JSONContentType = "application/json"
	XContentTypeKey = "Content-Type"
)

HTTP Header for security.

Variables

View Source
var (
	TLSConfiguration = &tls.Config{
		MinVersion:               tls.VersionTLS12,
		CurvePreferences:         []tls.CurveID{tls.CurveP521, tls.CurveP384, tls.CurveP256},
		PreferServerCipherSuites: true,
		CipherSuites: []uint16{
			tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
			tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
			tls.TLS_RSA_WITH_AES_256_GCM_SHA384,
			tls.TLS_RSA_WITH_AES_256_CBC_SHA,
		},
	}

	TLSNextProto = make(map[string]func(*http.Server, *tls.Conn, http.Handler))
)

TLS configuration for https server. like accepted ciphers

Functions

func EndTrip

func EndTrip(
	ctx context.Context,
	logger logging.Logger,
	statter stats.Statter) func(http.ResponseWriter, *http.Request)

EndTrip is the handler for starting a trip.

func Erroring

func Erroring(_ context.Context, w http.ResponseWriter, err error, logger logging.Logger)

Erroring centralize the error handling on the transport layer.

func GatewayEndTrip

func GatewayEndTrip(
	ctx context.Context,
	conf configuration.GatewayConfiguration,
	logger logging.Logger,
	statter stats.Statter) func(http.ResponseWriter, *http.Request)

GatewayEndTrip is the handler for starting a trip.

func GatewayGetBikeByID

func GatewayGetBikeByID(ctx context.Context,
	conf configuration.GatewayConfiguration,
	logger logging.Logger,
	statter stats.Statter) func(http.ResponseWriter, *http.Request)

GatewayGetBikeByID returns a bike given an ID.

func GatewayListOfBikes

func GatewayListOfBikes(ctx context.Context,
	conf configuration.GatewayConfiguration,
	logger logging.Logger,
	statter stats.Statter,
) func(http.ResponseWriter, *http.Request)

GatewayListOfBikes returns a paginated list of bikes.

func GatewayStartTrip

func GatewayStartTrip(
	ctx context.Context,
	conf configuration.GatewayConfiguration,
	logger logging.Logger,
	statter stats.Statter) func(http.ResponseWriter, *http.Request)

GatewayStartTrip is the handler for starting a trip.

func GetBikeByID

func GetBikeByID(ctx context.Context,
	conf configuration.BikeConfiguration,
	logger logging.Logger,
	statter stats.Statter) func(http.ResponseWriter, *http.Request)

GetBikeByID returns a bike given an ID.

func GetPaginationArguments

func GetPaginationArguments(req *http.Request) (string, int64)

GetPaginationArguments extract limit and cursor from request.

func ListOfBikes

func ListOfBikes(ctx context.Context,
	conf configuration.BikeConfiguration,
	logger logging.Logger,
	statter stats.Statter,
) func(http.ResponseWriter, *http.Request)

ListOfBikes returns a paginated list of bikes.

func LockBikeByID

func LockBikeByID(ctx context.Context,
	conf configuration.BikeConfiguration,
	logger logging.Logger,
	statter stats.Statter) func(http.ResponseWriter, *http.Request)

LockBikeByID lock a bike given an ID.

func NewBikeService

func NewBikeService(
	ctx context.Context,
	m Metadata,
	conf configuration.BikeConfiguration,
	logger logging.Logger,
	statter stats.Statter) (*http.Server, error)

NewBikeService returns the bike service wrapped in a valid http.Server.

func NewGatewayService

func NewGatewayService(
	ctx context.Context,
	m Metadata,
	conf configuration.GatewayConfiguration,
	logger logging.Logger,
	statter stats.Statter,
	messenger messaging.Emitter) (*http.Server, error)

NewGatewayService returns the gateway service wrapped in a valid http.Server.

func NewServer

func NewServer(ctx context.Context, conf configuration.Server, router http.Handler) (*http.Server, error)

NewServer sets up HTTP the server.

func NewTripService

func NewTripService(
	ctx context.Context,
	m Metadata,
	conf configuration.TripConfiguration,
	logger logging.Logger,
	statter stats.Statter) (*http.Server, error)

NewTripService returns the trip service wrapped in a valid http.Server.

func StartTrip

func StartTrip(
	ctx context.Context,
	logger logging.Logger,
	statter stats.Statter) func(http.ResponseWriter, *http.Request)

StartTrip is the handler for starting a trip.

func TrackTrip

TrackTrip is the middleware for tracking a trip. By tracking, we mean here, adding a location to a trip.

func UnLockBikeByID

func UnLockBikeByID(ctx context.Context,
	conf configuration.BikeConfiguration,
	logger logging.Logger,
	statter stats.Statter) func(http.ResponseWriter, *http.Request)

UnLockBikeByID lock a bike given an ID.

Types

type Metadata

type Metadata map[string]interface{}

Metadata holds build metadatas.

Jump to

Keyboard shortcuts

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