web

package
v0.0.0-...-e5949e2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2018 License: BSD-2-Clause Imports: 13 Imported by: 1

Documentation

Overview

Package web is a pretty basic web server at this point.

Manual Testing with curl:

curl --header "Content-Type: application/json" --request POST --data '{"username":"xyz","password":"xyz"}' http://localhost:8080/api/fred
curl -X GET -H "Content-type: application/json" -H "Accept: application/json"  "http://localhost:8080/api/fred"

Load Testing with vegeta

BaxterBot vegeta --addr http://10.41.45.222:8080 | vegeta attack -duration 10s  | tee /tmp/report.bin | vegeta report -type=text && cat /tmp/report.bin | vegeta plot > /tmp/page.html && open /tmp/page.html

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Start

func Start(options ...Option) error

Start creates and starts an HTTP server on port 8080, or a different port if one is provided as an option.

Options that can be included are:

Port
	Sets the port that the http.Server will run on.
RequestsPerSecond
	Sets the rate limiter to only allow a set amount of HTTP requests per second.
	Automatically sets the Burst to be 10% of the RequestsPerSecond value.
Wait
	Uses the rate.Limiter Wait protocol instead of Allow.

Types

type Option

type Option func(*Options)

Option custom type

func Port

func Port(port string) Option

Port defines on which TCP/IP port the web server will run on

func RequestsPerSecond

func RequestsPerSecond(rps int64) Option

RequestsPerSecond defines how many HTTP requests can be handled per second of real time.

func Wait

func Wait() Option

Wait specifies we should use the wait protocol versuses the allow.

type Options

type Options struct {
	Port             string
	RequestPerSecond int64
	Burst            int
	Wait             mux.MiddlewareFunc
}

Options contain the configuration for the web server

Jump to

Keyboard shortcuts

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