Documentation ¶
Overview ¶
Package handler provides common functions needed to create API handlers as well as some utilities
Index ¶
Constants ¶
const LogFieldNameFunction = "function"
LogFieldNameFunction defines the field-name for structured logging of cuntions
Variables ¶
This section is empty.
Functions ¶
func LogFunction ¶
LogFunction uses the function name to perform structured logging with a field
func ServeStaticDir ¶
ServeStaticDir acts as a FileServer and serves the contents of the given dir
func ServeStaticFile ¶
ServeStaticFile acts as a FileServer for a single file and serves the specified file
Types ¶
type AppInfoHandler ¶
type AppInfoHandler struct { Handler // Version of the application using https://semver.org/ Version string // Build identifies the specific build, e.g. git-hash Build string }
AppInfoHandler is responsible to return meta-information about the application
func (*AppInfoHandler) HandleAppInfo ¶
func (a *AppInfoHandler) HandleAppInfo(user security.User, w http.ResponseWriter, r *http.Request) error
swagger:operation GET /appinfo appinfo HandleAppInfo
provides information about the application
meta-data of the application including authenticated user and version
--- produces: - application/json responses:
'200': description: Meta schema: "$ref": "#/definitions/Meta" '401': description: ProblemDetail schema: "$ref": "#/definitions/ProblemDetail" '403': description: ProblemDetail schema: "$ref": "#/definitions/ProblemDetail"
type AppInfoResponse ¶
type AppInfoResponse struct {
*Meta
}
Response wraps the data struct into a framework response
func (AppInfoResponse) Render ¶
func (a AppInfoResponse) Render(w http.ResponseWriter, r *http.Request) error
Render the specific response
type Handler ¶
type Handler struct { // ErrRep is used to send errors according to the users accept headers ErrRep *errors.ErrorReporter }
Handler defines common handler logic
func (*Handler) Call ¶
func (h *Handler) Call(f func(w http.ResponseWriter, r *http.Request) error) http.HandlerFunc
Call wraps handlers to have a common signature
type Meta ¶
type Meta struct { UserInfo UserInfo `json:"userInfo"` Version VersionInfo `json:"versionInfo"` }
Meta specifies application metadata swagger:model
type TemplateHandler ¶
type TemplateHandler struct { Handler CookieSettings cookies.Settings Version string Build string AppName string TemplateDir string }
TemplateHandler is used to display errors using HTML templates
func (*TemplateHandler) HandleError ¶
func (h *TemplateHandler) HandleError(w http.ResponseWriter, r *http.Request) error
HandleError returns a HTML template showing errors
type UserInfo ¶
type UserInfo struct { DisplayName string `json:"displayName"` UserID string `json:"userId"` UserName string `json:"userName"` Email string `json:"email"` Roles []string `json:"roles"` }
UserInfo provides information about the currently logged-in user swagger:model
type VersionInfo ¶
VersionInfo is used to provide version and build swagger:model