Documentation
¶
Index ¶
- func DefaultErrorHandler(ctx *Ctx, err error) error
- func FingerprintCertificate(cert *x509.Certificate) []byte
- func FingerprintCertificateWithHash(cert *x509.Certificate, hashType crypto.Hash) []byte
- func NewError(message string, status Status) error
- type App
- type AppConfigFunction
- func WithDebugModeEnabled() AppConfigFunction
- func WithDisableStartupMessage() AppConfigFunction
- func WithErrorHandler(eh ErrorHandlerFunction) AppConfigFunction
- func WithLogger(x *log.Logger) AppConfigFunction
- func WithReadTimeout(x time.Duration) AppConfigFunction
- func WithServerName(name string) AppConfigFunction
- func WithWriteTimeout(x time.Duration) AppConfigFunction
- func WithX509KeyData(certPEMBlock, keyPEMBlock []byte) AppConfigFunction
- func WithX509KeyPair(certFile, keyFile string) AppConfigFunction
- type Ctx
- func (ctx *Ctx) ClearBody()
- func (ctx *Ctx) GetBody() *[]byte
- func (ctx *Ctx) GetClientCertificates() []*x509.Certificate
- func (ctx *Ctx) GetMeta() *[]byte
- func (ctx *Ctx) GetRawQuery() string
- func (ctx *Ctx) GetRawQueryWithDefault(defaultValue string) string
- func (ctx *Ctx) GetRemoteAddress() net.Addr
- func (ctx *Ctx) GetRequestURL() *url.URL
- func (ctx *Ctx) GetURLParam(name string) string
- func (ctx *Ctx) GetURLParamWithDefault(name, defaultValue string) string
- func (ctx *Ctx) Next() error
- func (ctx *Ctx) SetBody(body string)
- func (ctx *Ctx) SetBodyBuilder(sb *strings.Builder)
- func (ctx *Ctx) SetBodyFromFile(filename string) error
- func (ctx *Ctx) SetMeta(meta string) error
- func (ctx *Ctx) SetStatus(status Status)
- type Error
- type ErrorHandlerFunction
- type HandlerFunction
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultErrorHandler ¶
func FingerprintCertificate ¶
func FingerprintCertificate(cert *x509.Certificate) []byte
FingerprintCertificate computes a SHA1 hash of the raw certificate bytes.
func FingerprintCertificateWithHash ¶
func FingerprintCertificateWithHash(cert *x509.Certificate, hashType crypto.Hash) []byte
FingerprintCertificateWithHash computes a hash of a given type from the raw certificate bytes.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
func New ¶
func New(conf ...AppConfigFunction) (*App, error)
func (*App) Add ¶
func (app *App) Add(path string, handlerFunction HandlerFunction)
Add registers a handler function to be used to serve requests to a specific URL.
func (*App) Use ¶
func (app *App) Use(hf HandlerFunction)
func (*App) UseOnPath ¶
func (app *App) UseOnPath(path string, hf HandlerFunction)
type AppConfigFunction ¶
func WithDebugModeEnabled ¶
func WithDebugModeEnabled() AppConfigFunction
func WithDisableStartupMessage ¶
func WithDisableStartupMessage() AppConfigFunction
func WithErrorHandler ¶
func WithErrorHandler(eh ErrorHandlerFunction) AppConfigFunction
WithErrorHandler sets the error handler that's used by the app.
The error handler must not make use of request variables. The error handler must not call (*ctx).Next()
func WithLogger ¶
func WithLogger(x *log.Logger) AppConfigFunction
WithLogger sets the error logger to the one provided.
To disable logging, use this function with a nil logger.
func WithReadTimeout ¶
func WithReadTimeout(x time.Duration) AppConfigFunction
WithReadTimeout sets the read timeout for any incoming connections.
Setting this value to zero disables read timeouts.
func WithServerName ¶
func WithServerName(name string) AppConfigFunction
func WithWriteTimeout ¶
func WithWriteTimeout(x time.Duration) AppConfigFunction
WithWriteTimeout sets the write timeout for any incoming connections.
Setting this value to zero disables write timeouts.
func WithX509KeyData ¶
func WithX509KeyData(certPEMBlock, keyPEMBlock []byte) AppConfigFunction
WithX509KeyData loads an X509 certificate and key from the provided bytes.
func WithX509KeyPair ¶
func WithX509KeyPair(certFile, keyFile string) AppConfigFunction
WithX509KeyPair loads an X509 certificate file and key file from disk.
type Ctx ¶
type Ctx struct {
// contains filtered or unexported fields
}
func (*Ctx) GetClientCertificates ¶
func (ctx *Ctx) GetClientCertificates() []*x509.Certificate
func (*Ctx) GetRawQuery ¶
func (*Ctx) GetRawQueryWithDefault ¶
func (*Ctx) GetRemoteAddress ¶
func (*Ctx) GetRequestURL ¶
func (*Ctx) GetURLParam ¶
func (*Ctx) GetURLParamWithDefault ¶
func (*Ctx) SetBody ¶
SetBody sets the response body to a single string. This will be overridden if (*ctx).SetBodyBuilder is used.
func (*Ctx) SetBodyBuilder ¶
SetBodyBuilder allows a strings.Builder to be used to create the response body. This will overwrite any other calls made to set the response body.
To undo this, call SetBodyBuilder with a nil *strings.Builder then call other body-setting functions as normal.
func (*Ctx) SetBodyFromFile ¶
SetBodyFromFile reads a file with the specified name and uses its contents as the response body. This will be overridden if (*ctx).SetBodyBuilder is used.
type ErrorHandlerFunction ¶
type HandlerFunction ¶
type Status ¶
type Status int
const ( StatusInput Status = 10 StatusSensitiveInput Status = 11 StatusSuccess Status = 20 StatusTemporaryRedirect Status = 30 StatusPermanentRedirect Status = 31 StatusTemporaryFailure Status = 40 StatusCGIError Status = 42 StatusProxyError Status = 43 StatusSlowDown Status = 44 StatusPermanentFailure Status = 50 StatusNotFound Status = 51 StatusGone Status = 52 StatusProxyRequestRefused Status = 53 StatusBadRequest Status = 59 StatusClientCertificateRequired Status = 60 StatusCertificateNotAuthorised Status = 61 StatusCertificateNotValid Status = 62 )