Documentation
¶
Index ¶
- Constants
- Variables
- func HTTPStaticDefaultHook(w http.ResponseWriter, _ *http.Request, fileInfo fs.FileInfo)
- func ReadAllButRetain(reader io.ReadCloser) []byte
- type App
- type Authenticator
- type CSP
- type HTTPBasicAuth
- type HTTPClient
- type HTTPClientMiddleware
- type HTTPClientResponseMiddleware
- type HTTPHeaders
- type HTTPLogger
- type HTTPOAuth2
- type HTTPOAuth2Grant
- type HTTPOAuth2GrantPassword
- type HTTPOAuth2Token
- type HTTPRouter
- type HTTPStatic
- type HandlerContext
- func (handlerContext *HandlerContext) Deadline() (time.Time, bool)
- func (handlerContext *HandlerContext) DecodeRequest(target any) error
- func (handlerContext *HandlerContext) Done() <-chan struct{}
- func (handlerContext *HandlerContext) Err() error
- func (handlerContext *HandlerContext) ExecuteTemplate(tmpl *template.Template, data any)
- func (handlerContext *HandlerContext) ReadBody() []byte
- func (handlerContext *HandlerContext) RespondHTML(status int, s string)
- func (handlerContext *HandlerContext) RespondJSON(status int, v any)
- func (handlerContext *HandlerContext) Value(key any) any
- type Log
- type LogSupplementerFunc
- type Logger
- func (logger *Logger) Copy(newChannel string) *Logger
- func (logger *Logger) Critical(cxt context.Context, message string, extras map[string]any)
- func (logger *Logger) Debug(cxt context.Context, message string, extras map[string]any)
- func (logger *Logger) Error(cxt context.Context, message string, extras map[string]any)
- func (logger *Logger) Info(cxt context.Context, message string, extras map[string]any)
- func (logger *Logger) Log(ctx context.Context, level string, message string, extras map[string]any)
- func (logger *Logger) StandardLogger() *log.Logger
- func (logger *Logger) Warning(cxt context.Context, message string, extras map[string]any)
- func (logger *Logger) Write(b []byte) (int, error)
- type LoggerErrorExtrasAdder
- type Resources
- type Runtime
- type User
- type Validator
- type ValidatorError
Constants ¶
View Source
const ( HeaderContentType = "Content-Type" HeaderCacheControl = "Cache-Control" HeaderContentSecurityPolicy = "Content-Security-Policy" )
View Source
const ( LevelCritical = "CRITICAL" LevelError = "ERROR" LevelWarning = "WARNING" LevelInfo = "INFO" LevelDebug = "DEBUG" )
Variables ¶
View Source
var ( ErrInvalidValue = errors.New("value must be a non-nil pointer to a struct") ErrUnsupportedFieldType = errors.New("field is an unsupported type") ErrUnexportedField = errors.New("field must be exported") ErrNotAuthenticated = errors.New("not authenticated") )
View Source
var ErrBodyCanNotBeBlank = errors.New("request body can not be blank")
View Source
var ErrHTTPClientShouldRetry = errors.New("")
Functions ¶
func HTTPStaticDefaultHook ¶ added in v0.0.27
func ReadAllButRetain ¶ added in v0.0.32
func ReadAllButRetain(reader io.ReadCloser) []byte
Types ¶
type Authenticator ¶
type HTTPBasicAuth ¶ added in v0.0.32
func (HTTPBasicAuth) CheckResponse ¶ added in v0.0.32
func (httpBasicAuth HTTPBasicAuth) CheckResponse(r *http.Response) error
func (HTTPBasicAuth) ModifyRequest ¶ added in v0.0.32
func (httpBasicAuth HTTPBasicAuth) ModifyRequest(r *http.Request) error
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
func NewHTTPClient ¶
func NewHTTPClient( httpClient *http.Client, middleware []HTTPClientMiddleware, ) *HTTPClient
func (*HTTPClient) JSONRequest ¶ added in v0.0.32
type HTTPClientMiddleware ¶ added in v0.0.32
type HTTPClientResponseMiddleware ¶ added in v0.0.32
type HTTPHeaders ¶ added in v0.0.32
func (HTTPHeaders) CheckResponse ¶ added in v0.0.32
func (httpHeaders HTTPHeaders) CheckResponse(r *http.Response) error
func (HTTPHeaders) ModifyRequest ¶ added in v0.0.32
func (httpHeaders HTTPHeaders) ModifyRequest(r *http.Request) error
type HTTPLogger ¶
func (*HTTPLogger) ServeHTTP ¶
func (httpLogger *HTTPLogger) ServeHTTP(w http.ResponseWriter, r *http.Request)
type HTTPOAuth2 ¶ added in v0.0.32
type HTTPOAuth2 struct {
// contains filtered or unexported fields
}
func NewHTTPOAuth2 ¶ added in v0.0.32
func NewHTTPOAuth2( client *http.Client, grant HTTPOAuth2Grant, tokenURL string, ) *HTTPOAuth2
func (*HTTPOAuth2) CheckResponse ¶ added in v0.0.32
func (oauth2 *HTTPOAuth2) CheckResponse(r *http.Response) error
func (*HTTPOAuth2) ModifyRequest ¶ added in v0.0.32
func (oauth2 *HTTPOAuth2) ModifyRequest(r *http.Request) error
type HTTPOAuth2Grant ¶ added in v0.0.32
type HTTPOAuth2GrantPassword ¶ added in v0.0.32
type HTTPOAuth2GrantPassword struct {
ClientID string
ClientSecret string
Username string
Password string
Scope string
}
func (HTTPOAuth2GrantPassword) GenerateQuery ¶ added in v0.0.32
func (grant HTTPOAuth2GrantPassword) GenerateQuery() (url.Values, error)
type HTTPOAuth2Token ¶ added in v0.0.32
type HTTPOAuth2Token struct {
AccessToken string `json:"access_token"`
}
type HTTPRouter ¶
func (*HTTPRouter) ServeHTTP ¶
func (httpRouter *HTTPRouter) ServeHTTP(w http.ResponseWriter, r *http.Request)
type HTTPStatic ¶
type HTTPStatic struct {
FileSystem http.FileSystem
IndexFile string
NotFoundFile string
NotFoundCode int
NotFoundHandler func(w http.ResponseWriter, r *http.Request, httpStatic *HTTPStatic)
Hook func(w http.ResponseWriter, r *http.Request, fileInfo fs.FileInfo)
}
func (*HTTPStatic) ServeFile ¶ added in v0.0.28
func (httpStatic *HTTPStatic) ServeFile(w http.ResponseWriter, r *http.Request, file http.File, fileInfo fs.FileInfo, statusCode int)
func (*HTTPStatic) ServeHTTP ¶
func (httpStatic *HTTPStatic) ServeHTTP(w http.ResponseWriter, r *http.Request)
type HandlerContext ¶
type HandlerContext struct {
Writer http.ResponseWriter
Request *http.Request
}
func NewHandlerContext ¶
func NewHandlerContext(w http.ResponseWriter, r *http.Request) *HandlerContext
func (*HandlerContext) Deadline ¶ added in v0.0.25
func (handlerContext *HandlerContext) Deadline() (time.Time, bool)
func (*HandlerContext) DecodeRequest ¶
func (handlerContext *HandlerContext) DecodeRequest(target any) error
func (*HandlerContext) Done ¶ added in v0.0.25
func (handlerContext *HandlerContext) Done() <-chan struct{}
func (*HandlerContext) Err ¶ added in v0.0.25
func (handlerContext *HandlerContext) Err() error
func (*HandlerContext) ExecuteTemplate ¶ added in v0.0.17
func (handlerContext *HandlerContext) ExecuteTemplate(tmpl *template.Template, data any)
func (*HandlerContext) ReadBody ¶
func (handlerContext *HandlerContext) ReadBody() []byte
func (*HandlerContext) RespondHTML ¶
func (handlerContext *HandlerContext) RespondHTML(status int, s string)
func (*HandlerContext) RespondJSON ¶
func (handlerContext *HandlerContext) RespondJSON(status int, v any)
func (*HandlerContext) Value ¶ added in v0.0.25
func (handlerContext *HandlerContext) Value(key any) any
type LogSupplementerFunc ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func NewLogger ¶
func NewLogger( channel string, writer io.Writer, supplementer LogSupplementerFunc, ) *Logger
func (*Logger) StandardLogger ¶
type LoggerErrorExtrasAdder ¶ added in v0.0.19
type Resources ¶
type Resources struct {
// contains filtered or unexported fields
}
func NewResources ¶
func (*Resources) MustOpenDirectory ¶
func (*Resources) MustOpenFileContents ¶
type Runtime ¶
type Runtime struct {
Environment *environment.Environment
Stdout io.Writer
Stderr io.Writer
Stdin io.Reader
FS fs.FS
}
func NewRuntime ¶
func NewRuntime() *Runtime
func (*Runtime) KeepRunning ¶
type ValidatorError ¶
type ValidatorError struct {
Message string
}
func (ValidatorError) Error ¶
func (err ValidatorError) Error() string
Click to show internal directories.
Click to hide internal directories.