### ListenAndServe Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Starts the HTTP server using the configuration provided during initialization. ```APIDOC ## func (*Atreugo) ListenAndServe() error ### Description Serves requests from the network and address specified in the Atreugo configuration. ``` -------------------------------- ### Manage Server Lifecycle and Connections Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Methods for starting the server, handling connections, and performing graceful shutdowns. ```go func (s *Atreugo) ListenAndServe() error ``` ```go func (s *Atreugo) Serve(ln net.Listener) error ``` ```go func (s *Atreugo) ServeConn(c net.Conn) error ``` ```go func (s *Atreugo) ServeGracefully(ln net.Listener) error ``` ```go func (s *Atreugo) Shutdown() (err error) ``` -------------------------------- ### Install Atreugo Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Command to install the Atreugo package via go get. ```bash go get github.com/savsgio/atreugo/v11 ``` -------------------------------- ### Check for prefork child process Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Determines if the current execution context is a child process in a prefork setup. ```go func IsPreforkChild() bool ``` -------------------------------- ### Initialize Atreugo Server Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Creates a new instance of the Atreugo server using the provided configuration. ```go func New(cfg Config) *Atreugo ``` -------------------------------- ### New Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Creates a new instance of the Atreugo server. ```APIDOC ## func New(cfg Config) *Atreugo ### Description Creates a new instance of the Atreugo Server using the provided configuration. ### Parameters - **cfg** (Config) - Required - The configuration object for the server. ``` -------------------------------- ### Serve static files Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Serves files from a root directory. Ensure the system ulimit is sufficient for the number of files. ```go func (r *Router) Static(url, rootPath string) *Path ``` -------------------------------- ### UseBefore Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Registers middlewares to execute before the view. ```go func (p *Path) UseBefore(fns ...Middleware) *Path ``` -------------------------------- ### Serve static files with custom configuration Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Serves files using a custom StaticFS configuration. ```go func (r *Router) StaticCustom(url string, fs *StaticFS) *Path ``` -------------------------------- ### Configure Virtual Hosts Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Creates a sub-router for managing multiple websites on a single Atreugo instance. ```go func (s *Atreugo) NewVirtualHost(hostnames ...string) *Router ``` -------------------------------- ### Serve a single file Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Returns an HTTP response containing the contents of a file, with optional compression. ```go func (r *Router) ServeFile(url, filePath string) *Path ``` -------------------------------- ### UseAfter Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Registers middlewares to execute after the view. ```go func (p *Path) UseAfter(fns ...Middleware) *Path ``` -------------------------------- ### Router NetHTTPPath Method Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Wraps a net/http handler for use in Atreugo. Use only for quick migration as it has performance overhead. ```go func (r *Router) NetHTTPPath(method, url string, handler http.Handler) *Path ``` -------------------------------- ### Router HTTP Method Shortcuts Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Shortcut methods for registering routes by HTTP method. ```go func (r *Router) ANY(url string, viewFn View) *Path ``` ```go func (r *Router) DELETE(url string, viewFn View) *Path ``` ```go func (r *Router) GET(url string, viewFn View) *Path ``` ```go func (r *Router) HEAD(url string, viewFn View) *Path ``` ```go func (r *Router) OPTIONS(url string, viewFn View) *Path ``` ```go func (r *Router) PATCH(url string, viewFn View) *Path ``` -------------------------------- ### Serve static files from fs.FS Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Serves files from a standard Go filesystem interface. ```go func (r *Router) StaticFS(url string, filesystem fs.FS) *Path ``` -------------------------------- ### StaticFS configuration structure Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Defines the settings for serving static files, including compression and index page generation. ```go type StaticFS struct { // FS is filesystem to serve files from. eg: embed.FS os.DirFS FS fs.FS // Path to the root directory to serve files from. Root string // AllowEmptyRoot controls what happens when Root is empty. When false (default) it will default to the // current working directory. An empty root is mostly useful when you want to use absolute paths // on windows that are on different filesystems. On linux setting your Root to "/" already allows you to use // absolute paths on any filesystem. AllowEmptyRoot bool // List of index file names to try opening during directory access. // // For example: // // * index.html // * index.htm // * my-super-index.xml // // By default the list is empty. IndexNames []string // Index pages for directories without files matching IndexNames // are automatically generated if set. // // Directory index generation may be quite slow for directories // with many files (more than 1K), so it is discouraged enabling // index pages' generation for such directories. // // By default index pages aren't generated. GenerateIndexPages bool // Transparently compresses responses if set to true. // // The server tries minimizing CPU usage by caching compressed files. // It adds CompressedFileSuffix suffix to the original file name and // tries saving the resulting compressed file under the new file name. // So it is advisable to give the server write access to Root // and to all inner folders in order to minimize CPU usage when serving // compressed responses. // // Transparent compression is disabled by default. Compress bool } ``` -------------------------------- ### func (*Router) ServeFile Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Serves a file from the local filesystem. ```APIDOC ### func (*Router) ServeFile(url, filePath string) *Path Returns an HTTP response containing compressed file contents from the given path. ``` -------------------------------- ### HTTPResponse Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Returns a response with an HTML body. ```go func (ctx *RequestCtx) HTTPResponse(body string, statusCode ...int) error ``` -------------------------------- ### Atreugo Server Configuration Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Configuration struct for defining server behavior, including TLS, networking, and error handling. ```go type Config struct { Addr string // TLS/SSL options TLSEnable bool CertKey string CertFile string // TLSConfig optionally provides a TLS configuration for use // by Serve when TLSEnable is true. // // Note that this value is cloned by Serve, // so it's not possible to modify the configuration // with methods like tls.Config.SetSessionTicketKeys. // To use SetSessionTicketKeys, use Atreugo.Serve with a TLS Listener // instead. TLSConfig *tls.Config // Server name for sending in response headers. (default: Atreugo) Name string // Logger (optional) Logger Logger // Log debug traces // Disabled by default // // Deprecated: Will be remove it soon! Debug bool // Kind of network listener (default: tcp4) // The network must be "tcp", "tcp4", "tcp6" or "unix". Network string // Preforks master process (with all cores) between several child processes // increases performance significantly, because Go doesn't have to share // and manage memory between cores // // WARNING: using prefork prevents the use of any global state! // Things like in-memory caches won't work. // // WARNING: In Windows OS it's only supported when 'Reuseport' is enabled. Prefork bool // Run server with a TCP listener with SO_REUSEPORT option set. // Just supported tcp4 and tcp6. // // It is recommended to scale linearly, executing several instances (as many as usable logical CPUs) // of the same server in different processes, significantly increasing performance. // // IMPORTANT: If you use it without prefork, // each of these processes should be executed with GOMAXPROCS=1. // // See: https://www.nginx.com/blog/socket-sharding-nginx-release-1-9-1/. Reuseport bool // Shutdown gracefully shuts down the server without interrupting any active connections. // Shutdown works by first closing all open listeners and then waiting indefinitely for all connections // to return to idle and then shut down. // // WARNING: Windows is not supportted. GracefulShutdown bool // Signals from operating system to listen when GracefulShutdown is enabled. // // Default: SIGINT, SIGTERM GracefulShutdownSignals []os.Signal // Compress transparently the response body generated by handler if the request contains 'gzip' or 'deflate' // in 'Accept-Encoding' header. Compress bool // JSONMarshalFunc is used to marshal the response body to writer as JSON. JSONMarshalFunc JSONMarshalFunc // Configurable view which is called when no matching route is // found. If it is not set, http.NotFound is used. NotFoundView View // Configurable view which is called when a request // cannot be routed. // If it is not set, http.Error with http.StatusMethodNotAllowed is used. // The "Allow" header with allowed request methods is set before the handler // is called. MethodNotAllowedView View // Function to handle error returned by view. // It should be used to generate a error page and return the http error code // 500 (Internal Server Error). ErrorView ErrorView // Function to handle panics recovered from views. // It should be used to generate a error page and return the http error code // 500 (Internal Server Error). // The handler can be used to keep your server from crashing because of // unrecovered panics. PanicView PanicView // HeaderReceived is called after receiving the header // // non zero RequestConfig field values will overwrite the default configs HeaderReceived func(header *fasthttp.RequestHeader) fasthttp.RequestConfig // ContinueHandler is called after receiving the Expect 100 Continue Header // // https://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.2.3 // https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.1.1 // Using ContinueHandler a server can make decisioning on whether or not // to read a potentially large request body based on the headers // // The default is to automatically read request bodies of Expect 100 Continue requests // like they are normal requests ContinueHandler func(header *fasthttp.RequestHeader) bool // The maximum number of concurrent connections the server may serve. // // DefaultConcurrency is used if not set. Concurrency int } ``` -------------------------------- ### Configure Path Middlewares Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Middlewares defines the middlewares (before, after and skip) in the order in which you want to execute them only for the view. WARNING: The previous middlewares configuration could be overridden. ```go func (p *Path) Middlewares(middlewares Middlewares) *Path ``` -------------------------------- ### FileResponse Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Returns a streaming response with file data. ```go func (ctx *RequestCtx) FileResponse(fileName, filePath, mimeType string) error ``` -------------------------------- ### Serve Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Serves incoming connections from a specific listener. ```APIDOC ## func (*Atreugo) Serve(ln net.Listener) error ### Description Serves incoming connections from the given listener. This method blocks until the listener returns a permanent error. ### Parameters - **ln** (net.Listener) - Required - The network listener to serve requests from. ``` -------------------------------- ### Router ListPaths Method Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Returns all registered routes grouped by method. ```go func (r *Router) ListPaths() map[string][]string ``` -------------------------------- ### RequestCtx TextResponse Methods Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Returns a response with the body formatted as text. ```go func (ctx *RequestCtx) TextResponse(body string, statusCode ...int) error ``` ```go func (ctx *RequestCtx) TextResponseBytes(body []byte, statusCode ...int) error ``` -------------------------------- ### Register POST route Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Shortcut for registering a POST request handler. ```go func (r *Router) POST(url string, viewFn View) *Path ``` -------------------------------- ### UseFinal Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Registers middlewares that always execute after the view or group, regardless of response status. ```go func (p *Path) UseFinal(fns ...FinalMiddleware) *Path ``` -------------------------------- ### RequestCtx Next Method Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Passes control to the next middleware or view function. ```go func (ctx *RequestCtx) Next() error ``` -------------------------------- ### RequestCtx Value Method and Optimization Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Retrieves values from the context. Use SetUserValue/UserValue instead of context.WithValue to avoid extra allocations. ```go func (ctx *RequestCtx) Value(key any) any ``` ```go ctx.SetUserValue("myKey", "myValue") ctx.UserValue("myKey") ``` ```go ctx.AttachContext(context.WithValue(myCtx, "myKey", "myValue")) ctx.Value("myKey") ``` -------------------------------- ### Register PUT route Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Shortcut for registering a PUT request handler. ```go func (r *Router) PUT(url string, viewFn View) *Path ``` -------------------------------- ### Register pre-execution middleware Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Registers middlewares to execute before the view or group. ```go func (r *Router) UseBefore(fns ...Middleware) *Router ``` -------------------------------- ### Configure Router Behaviors Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Methods to toggle specific router features such as automatic OPTIONS handling, path redirection, and method checking. ```go func (s *Atreugo) HandleMethodNotAllowed(v bool) ``` ```go func (s *Atreugo) HandleOPTIONS(v bool) ``` ```go func (s *Atreugo) RedirectFixedPath(v bool) ``` ```go func (s *Atreugo) RedirectTrailingSlash(v bool) ``` ```go func (s *Atreugo) SaveMatchedRoutePath(v bool) ``` -------------------------------- ### Router Middlewares Method Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Defines middlewares for a view or group. Note that previous configurations may be overridden. ```go func (r *Router) Middlewares(middlewares Middlewares) *Router ``` -------------------------------- ### MatchedRoutePath Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Returns the matched route path. ```go func (ctx *RequestCtx) MatchedRoutePath() []byte ``` -------------------------------- ### SkipMiddlewares Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Registers middlewares to be skipped during view execution. ```go func (p *Path) SkipMiddlewares(fns ...Middleware) *Path ``` -------------------------------- ### HTTPResponseBytes Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Returns a response with an HTML body as bytes. ```go func (ctx *RequestCtx) HTTPResponseBytes(body []byte, statusCode ...int) error ``` -------------------------------- ### func (*Path) Middlewares Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Defines the middlewares (before, after, and skip) to be executed for a specific view path. Note that this configuration may override previous middleware settings. ```APIDOC ## func (*Path) Middlewares(middlewares Middlewares) *Path ### Description Defines the middlewares (before, after and skip) in the order in which you want to execute them only for the view. WARNING: The previous middlewares configuration could be overridden. ### Parameters - **middlewares** (Middlewares) - Required - A collection of middlewares defining the execution order and skips. ``` -------------------------------- ### Graceful Shutdown with Context Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Gracefully shuts down the server by closing listeners and waiting for idle connections or context timeout. ```go func (s *Atreugo) ShutdownWithContext(ctx context.Context) (err error) ``` -------------------------------- ### JSONResponse Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Returns a response with a JSON body. ```go func (ctx *RequestCtx) JSONResponse(body any, statusCode ...int) error ``` -------------------------------- ### Register post-execution middleware Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Registers middlewares to execute after the view or group. ```go func (r *Router) UseAfter(fns ...Middleware) *Router ``` -------------------------------- ### Router NewGroupPath Method Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Returns a new router instance for grouping paths. ```go func (r *Router) NewGroupPath(path string) *Router ``` -------------------------------- ### Define Middleware Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Middleware must process all incoming requests before/after defined views. ```go type Middleware View ``` -------------------------------- ### RequestCtx RedirectResponse Method Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Redirects the request to a specific URL. ```go func (ctx *RequestCtx) RedirectResponse(url string, statusCode int) error ``` -------------------------------- ### func (*Router) Static Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Serves static files from a directory. ```APIDOC ### func (*Router) Static(url, rootPath string) *Path Serves static files from the given file system root path. ``` -------------------------------- ### ErrorResponse Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Returns an error response. ```go func (ctx *RequestCtx) ErrorResponse(err error, statusCode ...int) error ``` -------------------------------- ### Router Methods Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Methods for defining routes and managing middleware within the Atreugo Router. ```APIDOC ## func (*Router) GET(url string, viewFn View) ### Description Registers a GET route with the specified URL and view function. ## func (*Router) POST(url string, viewFn View) ### Description Registers a POST route with the specified URL and view function. ## func (*Router) Middlewares(middlewares Middlewares) ### Description Defines the middlewares (before, after, and skip) for the view or group. ## func (*Router) NewGroupPath(path string) ### Description Returns a new router instance to group paths under a common prefix. ``` -------------------------------- ### RequestCtx RawResponse Methods Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Returns a response without encoding the body. ```go func (ctx *RequestCtx) RawResponse(body string, statusCode ...int) error ``` ```go func (ctx *RequestCtx) RawResponseBytes(body []byte, statusCode ...int) error ``` -------------------------------- ### Register custom path Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Registers a view with a specific method and path, useful for non-standard methods. ```go func (r *Router) Path(method, url string, viewFn View) *Path ``` -------------------------------- ### Define Path Configuration Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Path configuration of the registered view. It is prohibited copying Path values. ```go type Path struct { // contains filtered or unexported fields } ``` -------------------------------- ### AttachContext Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Attaches a context.Context to the RequestCtx. ```go func (ctx *RequestCtx) AttachContext(extraCtx context.Context) ``` -------------------------------- ### Register fasthttp handler Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Wraps a fasthttp request handler for use within the Atreugo router. ```go func (r *Router) RequestHandlerPath(method, url string, handler fasthttp.RequestHandler) *Path ``` -------------------------------- ### RequestCtx Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 A wrapper for fasthttp.RequestCtx providing additional functionality. ```go type RequestCtx struct { *fasthttp.RequestCtx // contains filtered or unexported fields } ``` -------------------------------- ### RequestCtx SkipView Method Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Sets a flag to skip view execution, typically used in before middlewares. ```go func (ctx *RequestCtx) SkipView() ``` -------------------------------- ### func (*Router) Path Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Registers a new view with a custom method and path. ```APIDOC ### func (*Router) Path(method, url string, viewFn View) *Path Registers a new view with the given path and method. This is intended for bulk loading or non-standardized/custom methods. ``` -------------------------------- ### func (*Router) POST Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Registers a new view for the POST method. ```APIDOC ### func (*Router) POST(url string, viewFn View) *Path Registers a new view for the POST method at the specified URL. ``` -------------------------------- ### Path.SkipMiddlewares Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Registers middlewares to be skipped during the execution of a view. ```APIDOC ## func (*Path) SkipMiddlewares(fns ...Middleware) *Path ### Description SkipMiddlewares registers the middlewares that you want to skip only when executing the view. ``` -------------------------------- ### Register final middleware Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Registers middlewares that execute after the view, regardless of whether a response was returned. ```go func (r *Router) UseFinal(fns ...FinalMiddleware) *Router ``` -------------------------------- ### RequestCtx.JSONResponse Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Returns a response with the body formatted as JSON. ```APIDOC ## func (*RequestCtx) JSONResponse(body any, statusCode ...int) error ### Description JSONResponse return response with body in json format. ``` -------------------------------- ### Router Structure Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 The Router dispatches requests to views. Do not copy Router values. ```go type Router struct { // contains filtered or unexported fields } ``` -------------------------------- ### Skip middlewares Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Configures specific middlewares to be skipped for a view or group. ```go func (r *Router) SkipMiddlewares(fns ...Middleware) *Router ``` -------------------------------- ### Define FinalMiddleware Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 FinalMiddleware must process all incoming requests after the other middlewares/view. ```go type FinalMiddleware func(*RequestCtx) ``` -------------------------------- ### Shutdown Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Gracefully shuts down the server. ```APIDOC ## func (*Atreugo) Shutdown() (err error) ### Description Gracefully shuts down the server without interrupting active connections. It closes all open listeners and waits for connections to return to idle. ``` -------------------------------- ### RequestCtx.FileResponse Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Returns a streaming response with file data. ```APIDOC ## func (*RequestCtx) FileResponse(fileName, filePath, mimeType string) error ### Description FileResponse return a streaming response with file data. ``` -------------------------------- ### Define PanicView Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 PanicView must process panics recovered from views, if it's defined in configuration. ```go type PanicView func(*RequestCtx, any) ``` -------------------------------- ### AttachedContext Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Returns the attached context.Context if it exists. ```go func (ctx *RequestCtx) AttachedContext() context.Context ``` -------------------------------- ### func (s *Atreugo) ShutdownWithContext(ctx context.Context) (err error) Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Gracefully shuts down the server without interrupting any active connections. It closes all open listeners and waits for connections to return to idle or for the context to timeout. ```APIDOC ## func (s *Atreugo) ShutdownWithContext(ctx context.Context) (err error) ### Description Gracefully shuts down the server without interrupting any active connections. ShutdownWithContext works by first closing all open listeners and then waiting for all connections to return to idle or context timeout and then shut down. ### Parameters - **ctx** (context.Context) - Required - The context to control the timeout for the shutdown process. ### Returns - **err** (error) - Returns an error if the shutdown fails. ``` -------------------------------- ### AcquireRequestCtx Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Retrieves an empty RequestCtx from the pool. ```go func AcquireRequestCtx(ctx *fasthttp.RequestCtx) *RequestCtx ``` -------------------------------- ### Timeout Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Sets a timeout and error message for the view, returning StatusRequestTimeout if exceeded. ```go func (p *Path) Timeout(timeout time.Duration, msg string) *Path ``` -------------------------------- ### TimeoutCode Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Sets a timeout, error message, and specific status code for the view. ```go func (p *Path) TimeoutCode(timeout time.Duration, msg string, statusCode int) *Path ``` -------------------------------- ### Define ErrorView Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 ErrorView must process error returned by view. ```go type ErrorView func(*RequestCtx, error, int) ``` -------------------------------- ### Path.Timeout Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Sets a timeout and error message for a view. ```APIDOC ## func (*Path) Timeout(timeout time.Duration, msg string) *Path ### Description Timeout sets the timeout and the error message to the view, which returns StatusRequestTimeout error with the given msg to the client if view didn't return during the given duration. ``` -------------------------------- ### Define Logger Interface Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Logger is used for logging messages. ```go type Logger interface { Print(v ...any) Printf(format string, args ...any) } ``` -------------------------------- ### Release request context Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Returns a RequestCtx to the pool. Do not access the context after calling this function. ```go func ReleaseRequestCtx(ctx *RequestCtx) ``` -------------------------------- ### Define XRequestIDHeader constant Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 The header name used for request identification. ```go const XRequestIDHeader = "X-Request-ID" ``` -------------------------------- ### Define a View function type Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 The View type defines the signature for functions that process incoming requests within the Atreugo framework. ```go type View func(*RequestCtx) error ``` -------------------------------- ### PathRewriteFunc Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Defines a function type for rewriting request paths. ```go type PathRewriteFunc func(ctx *RequestCtx) []byte ``` -------------------------------- ### func (*Router) PUT Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Registers a new view for the PUT method. ```APIDOC ### func (*Router) PUT(url string, viewFn View) *Path Registers a new view for the PUT method at the specified URL. ``` -------------------------------- ### Atreugo structure definition Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 The main Atreugo application structure which embeds the Router. ```go type Atreugo struct { *Router // contains filtered or unexported fields } ``` -------------------------------- ### Define JSONMarshalFunc Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Function signature for custom JSON marshaling. ```go type JSONMarshalFunc func(w io.Writer, value any) error ``` -------------------------------- ### RequestCtx RequestID Method Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Retrieves the X-Request-ID header value. ```go func (ctx *RequestCtx) RequestID() []byte ``` -------------------------------- ### RequestCtx Methods Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Methods available on the RequestCtx object for managing request flow and generating responses. ```APIDOC ## func (*RequestCtx) Next() ### Description Passes control to the next middleware or view function. ## func (*RequestCtx) RawResponse(body string, statusCode ...int) ### Description Returns a response without encoding the body. ## func (*RequestCtx) RedirectResponse(url string, statusCode int) ### Description Redirects the request to a specific URL. ## func (*RequestCtx) RequestID() ### Description Returns the "X-Request-ID" header value. ## func (*RequestCtx) TextResponse(body string, statusCode ...int) ### Description Returns a response with the body in text format. ``` -------------------------------- ### Define JSON Type Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 JSON is a map whose key is a string and whose value an interface. ```go type JSON map[string]any ``` -------------------------------- ### Define Middlewares Collection Source: https://pkg.go.dev/github.com/savsgio/atreugo/v11 Middlewares is a collection of middlewares with the order of execution and which to skip. ```go type Middlewares struct { Before []Middleware After []Middleware Skip []Middleware Final []FinalMiddleware } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.