Documentation
¶
Index ¶
- Variables
- func AcceptsMarkdown(r *http.Request) bool
- func DocHandler(cfg *config.Config, assets Assets) http.HandlerFunc
- func DocOGImageHandler(cfg *config.Config, assets Assets) http.HandlerFunc
- func DocToMarkdown(cfg *config.Config, name string, content []byte) []byte
- func FileHandler(cfg *config.Config, database db.DB, assets Assets) http.HandlerFunc
- func FileToMarkdown(cfg *config.Config, file *snips.File, content []byte) []byte
- func HealthHandler(w http.ResponseWriter, _ *http.Request)
- func MetaHandler(cfg *config.Config) http.HandlerFunc
- func OGImageHandler(cfg *config.Config, database db.DB, assets Assets) http.HandlerFunc
- func Pattern(r *http.Request) string
- func ProfileHandler(w http.ResponseWriter, r *http.Request)
- func ShouldSendRaw(r *http.Request) bool
- func WithLogger(next http.Handler) http.Handler
- func WithMetrics(next http.Handler) http.Handler
- func WithMiddleware(handler http.Handler, middlewares ...Middleware) http.Handler
- func WithRecover(next http.Handler) http.Handler
- func WithRequestID(next http.Handler) http.Handler
- type Assets
- type ContextKey
- type Middleware
- type Service
- type StaticAssets
- func (a *StaticAssets) AssetPath(name string) string
- func (a *StaticAssets) CSS() []byte
- func (a *StaticAssets) Doc(filename string) ([]byte, error)
- func (a *StaticAssets) JS() []byte
- func (a *StaticAssets) README() []byte
- func (a *StaticAssets) Serve(w http.ResponseWriter, r *http.Request)
- func (a *StaticAssets) StaticFile(name string) ([]byte, bool)
- func (a *StaticAssets) Template() *template.Template
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultMiddleware = []Middleware{ WithRecover, WithMetrics, WithLogger, WithRequestID, }
Functions ¶
func AcceptsMarkdown ¶ added in v0.9.0
func DocHandler ¶
func DocHandler(cfg *config.Config, assets Assets) http.HandlerFunc
func DocOGImageHandler ¶ added in v0.9.0
func DocOGImageHandler(cfg *config.Config, assets Assets) http.HandlerFunc
func DocToMarkdown ¶ added in v0.9.0
func FileHandler ¶
func FileToMarkdown ¶ added in v0.9.0
func HealthHandler ¶
func HealthHandler(w http.ResponseWriter, _ *http.Request)
func MetaHandler ¶
func MetaHandler(cfg *config.Config) http.HandlerFunc
func OGImageHandler ¶ added in v0.9.0
func ProfileHandler ¶
func ProfileHandler(w http.ResponseWriter, r *http.Request)
func ShouldSendRaw ¶
func WithLogger ¶
WithLogger adds a request scoped logger to the request context.
func WithMetrics ¶
WithMetrics will record metrics for the request.
func WithMiddleware ¶
func WithMiddleware(handler http.Handler, middlewares ...Middleware) http.Handler
func WithRecover ¶
WithRecover will recover from any panics and log them.
Types ¶
type ContextKey ¶
type ContextKey string
const ( RequestIDContextKey ContextKey = "request_id" RequestIDHeader = "X-Request-ID" )
type StaticAssets ¶
type StaticAssets struct {
// contains filtered or unexported fields
}
func NewAssets ¶
func NewAssets(webFS fs.FS, docsFS fs.FS, readme []byte, extendHeadFile string) (*StaticAssets, error)
NewAssets holds the templates, static content and minifies accordingly.
func (*StaticAssets) AssetPath ¶ added in v0.8.0
func (a *StaticAssets) AssetPath(name string) string
AssetPath returns the hashed asset path for a given logical name (e.g. "index.css" → "/assets/index.a1b2c3d4.css").
func (*StaticAssets) CSS ¶
func (a *StaticAssets) CSS() []byte
func (*StaticAssets) JS ¶
func (a *StaticAssets) JS() []byte
func (*StaticAssets) README ¶
func (a *StaticAssets) README() []byte
func (*StaticAssets) Serve ¶
func (a *StaticAssets) Serve(w http.ResponseWriter, r *http.Request)
func (*StaticAssets) StaticFile ¶ added in v0.9.0
func (a *StaticAssets) StaticFile(name string) ([]byte, bool)
func (*StaticAssets) Template ¶
func (a *StaticAssets) Template() *template.Template
Click to show internal directories.
Click to hide internal directories.