webutils

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: MIT Imports: 7 Imported by: 0

README

webutils

Go Reference GoReport

Utilities for develop web applications in Go.

Installation

Use go get command to install webutils.

go get -u github.com/exepirit/webutils

Usage

You can find few examples in examples directory.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action func(app.Context) (interface{}, error)

type Hook

type Hook interface {
	SetResult(interface{}) Hook
	SetError(*error) Hook
	Use(composer app.Composer, ctx app.Context)
}

Hook is callback handler for applying on components asyncrhonious function side-effects.

func NewHook

func NewHook(act Action) Hook

NewHook creates new hook with specified action.

type Proxy

type Proxy struct {
	TargetAddr *url.URL
	PathPrefix string
}

Proxy is an HTTP handler that forward incoming client request and sends it to defined server.

Proxy replaces the prefix defined in PathPrefix by TargetAddr path.

func NewProxy

func NewProxy(target, prefix string) *Proxy

NewProxy returns new Proxy that routes requests with prefix to target server.

func (*Proxy) ServeHTTP

func (proxy *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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