Documentation ¶
Overview ¶
An HTTP server that manages connections and parses HTTP request messages into executable requests
Index ¶
- Constants
- func PercentDecode(field string) (decoded string, malformed error)
- func TCPServerBuilder(host string) *tcpServerBuilder
- type ConnectionHandler
- type DeleteResource
- type GetResource
- type HeadResource
- type LineRequestParser
- type Method
- type OptionsResource
- type PatchResource
- type PostResource
- type PutResource
- type QueryParameter
- type Request
- type RequestLineRouter
- type RequestLogger
- type RequestMessage
- func NewDeleteMessage(path string) RequestMessage
- func NewGetMessage(path string) RequestMessage
- func NewHeadMessage(path string) RequestMessage
- func NewOptionsMessage(targetAsteriskOrPath string) RequestMessage
- func NewPatchMessage(path string) RequestMessage
- func NewPostMessage(path string) RequestMessage
- func NewPutMessage(path string) RequestMessage
- func NewRequestMessage(method, path string) RequestMessage
- func NewTraceMessage(path string) RequestMessage
- type RequestParser
- type Resource
- type Response
- type Route
- type Router
- type TCPServer
- type UnfinishedPercentEncoding
Constants ¶
View Source
const ( CONNECT = "CONNECT" DELETE = "DELETE" GET = "GET" HEAD = "HEAD" OPTIONS = "OPTIONS" PATCH = "PATCH" POST = "POST" PUT = "PUT" TRACE = "TRACE" )
Request method verbs
View Source
const (
VERSION_1_1 = "HTTP/1.1"
)
Variables ¶
This section is empty.
Functions ¶
func PercentDecode ¶
func TCPServerBuilder ¶
func TCPServerBuilder(host string) *tcpServerBuilder
Builder for TCPServer that defaults to any available port on localhost
Types ¶
type ConnectionHandler ¶
type ConnectionHandler interface { Handle(request *bufio.Reader, response io.Writer) Routes() []Route }
func NewConnectionHandler ¶
func NewConnectionHandler(router Router) ConnectionHandler
type DeleteResource ¶
type DeleteResource interface {
Delete(client io.Writer, message RequestMessage)
}
type GetResource ¶
type GetResource interface {
Get(client io.Writer, message RequestMessage)
}
type HeadResource ¶
type HeadResource interface {
Head(client io.Writer, message RequestMessage)
}
type LineRequestParser ¶
type LineRequestParser struct{}
Parses an HTTP request message one line at a time.
type OptionsResource ¶
type OptionsResource interface {
Options(client io.Writer, message RequestMessage)
}
type PatchResource ¶
type PatchResource interface {
Patch(client io.Writer, message RequestMessage)
}
type PostResource ¶
type PostResource interface {
Post(client io.Writer, message RequestMessage)
}
type PutResource ¶
type PutResource interface {
Put(client io.Writer, message RequestMessage)
}
type QueryParameter ¶
type QueryParameter struct {
Name, Value string
}
type RequestLineRouter ¶
type RequestLineRouter struct { Parser RequestParser // contains filtered or unexported fields }
Routes requests based solely upon the first line in the request
func NewRouter ¶
func NewRouter() *RequestLineRouter
func (*RequestLineRouter) AddRoute ¶
func (router *RequestLineRouter) AddRoute(route Route)
func (*RequestLineRouter) LogRequests ¶
func (router *RequestLineRouter) LogRequests(logger RequestLogger)
func (RequestLineRouter) RouteRequest ¶
func (router RequestLineRouter) RouteRequest(reader *bufio.Reader) (ok Request, err Response)
func (*RequestLineRouter) Routes ¶
func (router *RequestLineRouter) Routes() []Route
type RequestLogger ¶
type RequestLogger interface {
Parsed(message RequestMessage)
}
type RequestMessage ¶
type RequestMessage interface { Method() string Target() string Version() string Path() string QueryParameters() []QueryParameter HeaderLines() []string HeaderValues(field string) (values []string) Body() []byte MakeResourceRequest(resource Resource) Request }
func NewDeleteMessage ¶
func NewDeleteMessage(path string) RequestMessage
func NewGetMessage ¶
func NewGetMessage(path string) RequestMessage
func NewHeadMessage ¶
func NewHeadMessage(path string) RequestMessage
func NewOptionsMessage ¶
func NewOptionsMessage(targetAsteriskOrPath string) RequestMessage
Creates an OPTIONS request to the specified target, which can either be a path starting with / or an asterisk-form query of the server as a whole (https://tools.ietf.org/html/rfc7230#section-5.3.4).
func NewPatchMessage ¶
func NewPatchMessage(path string) RequestMessage
func NewPostMessage ¶
func NewPostMessage(path string) RequestMessage
func NewPutMessage ¶
func NewPutMessage(path string) RequestMessage
func NewRequestMessage ¶
func NewRequestMessage(method, path string) RequestMessage
func NewTraceMessage ¶
func NewTraceMessage(path string) RequestMessage
type RequestParser ¶
type Resource ¶
type Resource interface {
Name() string
}
Handles requests of supported HTTP methods for a resource
type Route ¶
type Route interface {
Route(requested RequestMessage) Request
}
type TCPServer ¶
type TCPServer struct { Host string Port uint16 MaxConnections uint Handler ConnectionHandler // contains filtered or unexported fields }
type UnfinishedPercentEncoding ¶
type UnfinishedPercentEncoding struct {
EnclosingField string
}
func (UnfinishedPercentEncoding) Error ¶
func (invalid UnfinishedPercentEncoding) Error() string
Click to show internal directories.
Click to hide internal directories.