Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrorMiddleware = func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { ctx := context.WithValue(r.Context(), "error-handler", func(err error) { slog.Error(err.Error(), "request_id", r.Header.Get("X-Request-Id")) httputil.HandleError(w, httputil.NewError("", err, http.StatusInternalServerError)) }) next.ServeHTTP(w, r.WithContext(ctx)) }) }
View Source
var PostMiddleware = func(_ http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusNoContent) _, _ = w.Write(nil) }) }
View Source
var PreMiddleware = func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { _, r = tcontext.New(w, r) next.ServeHTTP(w, r) }) }
View Source
var ReadHeaderTimeout = 10 * time.Second
View Source
var RecoverMiddleware = func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer func() { if r := recover(); r != nil { if r == http.ErrAbortHandler { panic(r) } err, ok := r.(error) if !ok { err = fmt.Errorf("%v", r) } slog.Error(fmt.Sprintf("panic: %s", err.Error())) debug.PrintStack() w.WriteHeader(http.StatusInternalServerError) _, _ = w.Write([]byte(fmt.Sprintf("panic: %s", err.Error()))) return } }() next.ServeHTTP(w, r) }) }
View Source
var ServerInfo = "turna"
View Source
var ServerInfoMiddleware = func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Server", ServerInfo) next.ServeHTTP(w, r) }) }
Functions ¶
This section is empty.
Types ¶
type Certificate ¶
type HTTP ¶
type HTTP struct {
Routers map[string]Router `cfg:"routers"`
Middlewares map[string]HTTPMiddleware `cfg:"middlewares"`
TLS TLS `cfg:"tls"`
}
type HTTPMiddleware ¶
type HTTPMiddleware struct {
AddPrefixMiddleware *addprefix.AddPrefix `cfg:"add_prefix"`
InjectMiddleware *inject.Inject `cfg:"inject"`
HelloMiddleware *hello.Hello `cfg:"hello"`
TemplateMiddleware *template.Template `cfg:"template"`
InfoMiddleware *info.Info `cfg:"info"`
SetMiddleware *set.Set `cfg:"set"`
StripPrefixMiddleware *stripprefix.StripPrefix `cfg:"strip_prefix"`
RoleMiddleware *role.Role `cfg:"role"`
ScopeMiddleware *scope.Scope `cfg:"scope"`
ServiceMiddleware *service.Service `cfg:"service"`
FolderMiddleware *folder.Folder `cfg:"folder"`
BasicAuthMiddleware *basicauth.BasicAuth `cfg:"basic_auth"`
CorsMiddleware *cors.Cors `cfg:"cors"`
HeadersMiddleware *headers.Headers `cfg:"headers"`
BlockMiddleware *block.Block `cfg:"block"`
RegexPathMiddleware *regexpath.RegexPath `cfg:"regex_path"`
GzipMiddleware *gzip.Gzip `cfg:"gzip"`
DecompressMiddleware *decompress.Decompress `cfg:"decompress"`
LogMiddleware *log.Log `cfg:"log"`
PrintMiddleware *print.Print `cfg:"print"`
LoginMiddleware *login.Login `cfg:"login"`
SessionMiddleware *session.Session `cfg:"session"`
ViewMiddleware *view.View `cfg:"view"`
RequestMiddleware *request.Request `cfg:"request"`
RedirectionMiddleware *redirection.Redirection `cfg:"redirection"`
TryMiddleware *try.Try `cfg:"try"`
SessionInfoMiddleware *sessioninfo.Info `cfg:"session_info"`
IamMiddleware *iam.Iam `cfg:"iam"`
IamCheckMiddleware *iamcheck.IamCheck `cfg:"iam_check"`
RoleCheckMiddleware *rolecheck.RoleCheck `cfg:"role_check"`
RoleDataMiddleware *roledata.RoleData `cfg:"role_data"`
TokenPassMiddleware *tokenpass.TokenPass `cfg:"token_pass"`
RedirectContinueMiddleware *redirectcontinue.RedirectionContinue `cfg:"redirect_continue"`
ForwardMiddleware *forward.Forward `cfg:"forward"`
GrpcUIMiddleware *grpcui.GrpcUI `cfg:"grpcui"`
DNSPathMiddleware *dnspath.DNSPath `cfg:"dns_path"`
SplitterMiddleware *splitter.Splitter `cfg:"splitter"`
PathMiddleware *path.Path `cfg:"path"`
RequestIDMiddleware *requestid.RequestID `cfg:"request_id"`
Oauth2 *oauth2.Oauth2 `cfg:"oauth2"`
AccessLogMiddleware *accesslog.AccessLog `cfg:"access_log"`
}
type PreMiddlewares ¶ added in v0.7.8
type Router ¶
type Router struct {
Host string `cfg:"host"`
Path []string `cfg:"path"`
Middlewares []string `cfg:"middlewares"`
TLS *struct{} `cfg:"tls"`
EntryPoints []string `cfg:"entrypoints"`
PreMiddlewares PreMiddlewares `cfg:"pre_middlewares"`
}
type RouterHandler ¶ added in v0.7.1
type RuleRouter ¶
type RuleRouter struct {
// contains filtered or unexported fields
}
func NewRuleRouter ¶
func NewRuleRouter() *RuleRouter
func (*RuleRouter) GetMux ¶ added in v0.7.0
func (s *RuleRouter) GetMux(r RuleSelection) RouterHandler
func (RuleRouter) Serve ¶
func (s RuleRouter) Serve(entrypoint string) http.Handler
Serve implements the http.Handler interface with changing entrypoint selection.
func (*RuleRouter) ServeHTTP ¶
func (s *RuleRouter) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*RuleRouter) SetRule ¶
func (s *RuleRouter) SetRule(selection RuleSelection)
type RuleSelection ¶
type TLS ¶
type TLS struct {
Store map[string][]Certificate `cfg:"store"`
}
Click to show internal directories.
Click to hide internal directories.