httpserver

package
v0.8.8 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultHTTPServerBufferSize is the default size of the
	// buffer of in-coming HTTP request messages.
	DefaultHTTPServerBufferSize = 1024
)

Functions

func NewHTTPServerChan

func NewHTTPServerChan(ctx *dsl.Ctx, opts interface{}) (dsl.Chan, error)

Types

type HTTPServer

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

HTTPServer is an HTTP server Chan.

An HTTPServer will emit the requests it receives from HTTP clients, and the server should receive the responses to forward to those clients.

To use this channel, you first 'recv' a client request, and then you 'pub' the response, which the Chan will forward to the HTTP client.

Note that you have to do 'pub' each specific response for each client request.

func (*HTTPServer) Close

func (c *HTTPServer) Close(ctx *dsl.Ctx) error

func (*HTTPServer) DocSpec

func (c *HTTPServer) DocSpec() *dsl.DocSpec

func (*HTTPServer) Kill

func (c *HTTPServer) Kill(ctx *dsl.Ctx) error

func (*HTTPServer) Kind

func (c *HTTPServer) Kind() dsl.ChanKind

func (*HTTPServer) Open

func (c *HTTPServer) Open(ctx *dsl.Ctx) error

func (*HTTPServer) Pub

func (c *HTTPServer) Pub(ctx *dsl.Ctx, m dsl.Msg) error

func (*HTTPServer) Recv

func (c *HTTPServer) Recv(ctx *dsl.Ctx) chan dsl.Msg

func (*HTTPServer) Sub

func (c *HTTPServer) Sub(ctx *dsl.Ctx, topic string) error

func (*HTTPServer) To

func (c *HTTPServer) To(ctx *dsl.Ctx, m dsl.Msg) error

type HTTPServerOpts

type HTTPServerOpts struct {
	Host      string `json:"host"`
	Port      int    `json:"port"`
	ParseJSON bool   `json:"parsejson" yaml:"parsejson"`
}

HTTPServerOpts configures an HTTPServer channel.

type Request added in v0.5.1

type Request struct {
	Path string `json:"path"`

	// Form is the parsed form values.
	Form url.Values `json:"form,omitempty"`

	// Header is the map from header name to header values.
	Headers map[string][]string `json:"headers,omitempty"`

	// Method is the HTTP request method.
	Method string `json:"method"`

	// Body is the request body (if any).
	//
	// This body is parsed as JSON if ParsedJSON is true.
	Body interface{} `json:"body,omitempty"`

	// Error is a generic error message (if any).
	Error string `json:"error,omitempty"`
}

type Response added in v0.5.1

type Response struct {
	// Header is the map from header name to header values.
	Headers map[string][]string `json:"headers,omitempty"`

	// Body is the response body.
	Body interface{} `json:"body,omitempty"`

	StatusCode int `json:"statuscode,omitempty"`

	// Serialization is the serialization used to make a string
	// representation of the body.
	Serialization *dsl.Serialization `json:"serialization,omitempty"`
}

Jump to

Keyboard shortcuts

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