_examples/

directory
v14.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: BSD-3-Clause

Directories

Path Synopsis
01-getting-started
01-hello-world command
Step 1 of 13: the smallest Iris program.
Step 1 of 13: the smallest Iris program.
02-routes-and-params command
Step 2 of 13: routes, a router prefix and a typed path parameter.
Step 2 of 13: routes, a router prefix and a typed path parameter.
03-json-and-validation command
Step 3 of 13: a JSON body, validated before the handler sees it.
Step 3 of 13: a JSON body, validated before the handler sees it.
04-errors-mapped-once command
Step 4 of 13: domain errors, mapped to status codes exactly once.
Step 4 of 13: domain errors, mapped to status codes exactly once.
05-storage-behind-an-interface command
Step 5 of 13: storage behind an interface, rules in a service.
Step 5 of 13: storage behind an interface, rules in a service.
06-controllers command
Step 6 of 13: a controller instead of closures.
Step 6 of 13: a controller instead of closures.
07-nested-routes-and-guards command
Step 7 of 13: books under shelves, with guards.
Step 7 of 13: books under shelves, with guards.
08-pagination command
Step 8 of 13: a paginated list in one call.
Step 8 of 13: a paginated list in one call.
09-middleware command
Step 9 of 13: a middleware, and where it runs.
Step 9 of 13: a middleware, and where it runs.
10-admin-and-basicauth command
Step 10 of 13: an admin group behind basic authentication.
Step 10 of 13: an admin group behind basic authentication.
11-configuration command
Step 11 of 13: configuration from a file, secrets from the environment.
Step 11 of 13: configuration from a file, secrets from the environment.
12-newbuilder command
Step 12 of 13: the whole application on the iris.NewBuilder chain.
Step 12 of 13: the whole application on the iris.NewBuilder chain.
13-testing command
Step 13 of 13: the whole service tested in memory.
Step 13 of 13: the whole service tested in memory.
02-routing
custom-macro command
Custom path macros: a new constraint on a built-in parameter type, and a parameter type of your own.
Custom path macros: a new constraint on a built-in parameter type, and a parameter type of your own.
groups command
Route groups: child routers that inherit a path prefix and middleware.
Route groups: child routers that inherit a path prefix and middleware.
path-parameters command
Path parameters: typed macros in the route pattern, typed accessors in the handler.
Path parameters: typed macros in the route pattern, typed accessors in the handler.
routing-basics command
Routing basics: one function per HTTP method, and the Context helpers that carry the status code and the error branch for you.
Routing basics: one function per HTTP method, and the Context helpers that carry the status code and the error branch for you.
subdomains command
Subdomain routing: a router bound to a host label instead of a path prefix.
Subdomain routing: a router bound to a host label instead of a path prefix.
wrap-router command
Wrapping the router: raw net/http code that runs before any route matching.
Wrapping the router: raw net/http code that runs before any route matching.
03-controllers
basic command
Controllers: a constructor and a Routing method, mounted with app.Router.
Controllers: a constructor and a Routing method, mounted with app.Router.
mvc-generics command
Generic MVC controllers: five typed methods, the REST routes generated.
Generic MVC controllers: five typed methods, the REST routes generated.
nested-guards command
Nested controllers and the two guard idioms: a group guard for every route and a positional guard for single routes.
Nested controllers and the two guard idioms: a group guard for every route and a positional guard for single routes.
repository command
mvc.UseRepository: the six resource routes over a repository, with no controller in between.
mvc.UseRepository: the six resource routes over a repository, with no controller in between.
04-request
body-limits command
Capping request body size, app-wide and per route.
Capping request body size, app-wide and per route.
pagination command
A complete list endpoint in one call: ctx.Paginated.
A complete list endpoint in one call: ctx.Paginated.
query-and-forms command
Query strings and form bodies: the two places where client input arrives as loose key/value pairs.
Query strings and form bodies: the two places where client input arrives as loose key/value pairs.
raw-body command
ctx.ReadBody: the raw body, and one struct for every content type.
ctx.ReadBody: the raw body, and one struct for every content type.
read-json-optional command
An optional JSON request body with ctx.BindJSONOptional[T].
An optional JSON request body with ctx.BindJSONOptional[T].
read-json-validate command
Reading and validating a JSON body with ctx.BindJSON[T].
Reading and validating a JSON body with ctx.BindJSON[T].
strict-query command
Query parameters that refuse to be wrong, and partial updates that refuse to be silent.
Query parameters that refuse to be wrong, and partial updates that refuse to be silent.
uploads command
Multipart file uploads.
Multipart file uploads.
05-response
content-negotiation command
Content negotiation: one URL, several representations.
Content negotiation: one URL, several representations.
files command
File responses: inline, attachment, in-memory and rate-limited.
File responses: inline, attachment, in-memory and rate-limited.
rest-helpers command
The typed response helpers: one contract, ctx.Helper(value, err).
The typed response helpers: one contract, ctx.Helper(value, err).
streaming-ai command
One ai.Open handler that streams a model's answer or returns it as a single JSON document.
One ai.Open handler that streams a model's answer or returns it as a single JSON document.
streaming-sse command
Server-Sent Events with the sse package.
Server-Sent Events with the sse package.
writers command
The Context response writers: one format per route.
The Context response writers: one format per route.
06-middleware
accesslog command
Access logging: one structured record per request, with your own fields.
Access logging: one structured record per request, with your own fields.
cache command
Caching on two layers: client caching headers and server-side response caching.
Caching on two layers: client caching headers and server-side response caching.
conditional command
Conditional middleware: a debug bundle that runs only when the request asks for it.
Conditional middleware: a debug bundle that runs only when the request asks for it.
cors command
CORS: allowed origins, answered preflights and a JSON body for rejected origins.
CORS: allowed origins, answered preflights and a JSON body for rejected origins.
error-middleware command
Middleware that returns an error instead of writing a response.
Middleware that returns an error instead of writing a response.
i18n command
Internationalization: one message catalog, one language per request.
Internationalization: one message catalog, one language per request.
rate-limit command
Rate limiting: token buckets per authenticated principal, with Retry-After on rejection.
Rate limiting: token buckets per authenticated principal, with Retry-After on rejection.
request-id command
Request IDs: one identifier per request, in the response header and the logs.
Request IDs: one identifier per request, in the response header and the logs.
writing-middleware command
Writing your own middleware: a timing factory and two guards, each registered where its scope belongs.
Writing your own middleware: a timing factory and two guards, each registered where its scope belongs.
07-dependency-injection
constructors command
Constructor injection: a value, constructor functions and an interface parameter matched by method set.
Constructor injection: a value, constructor functions and an interface parameter matched by method set.
handler-func command
HandlerFunc: dependency injection for plain handlers and middleware.
HandlerFunc: dependency injection for plain handlers and middleware.
initializer command
Service lifecycle: iris.Initializer at startup, closers at shutdown.
Service lifecycle: iris.Initializer at startup, closers at shutdown.
request-scoped command
Request-scoped dependencies: the function itself is injected, not its result.
Request-scoped dependencies: the function itself is injected, not its result.
08-errors
central-error-map command
The central error map: domain sentinels classified in one place.
The central error map: domain sentinels classified in one place.
error-router command
errors.Router: handlers and middleware that return their errors.
errors.Router: handlers and middleware that return their errors.
handle-errorf command
errors.HandleErrorf: keep the classification, add the call site.
errors.HandleErrorf: keep the classification, add the call site.
validation-errors command
Field validation, end to end: Validate + validation.Join -> wire format.
Field validation, end to end: Validate + validation.Join -> wire format.
09-authentication
api-key command
API keys: authenticating a service, a cron job or a webhook sender.
API keys: authenticating a service, a cron job or a webhook sender.
auth-sdk command
The auth SDK: auth.Auth[T] with a provider, ready-made token handlers and per-router verification.
The auth SDK: auth.Auth[T] with a provider, ready-made token handlers and per-router verification.
basicauth command
HTTP Basic Authentication for an admin group.
HTTP Basic Authentication for an admin group.
jwt-middleware command
The jwt middleware: a Signer/Verifier round trip.
The jwt middleware: a Signer/Verifier round trip.
sessions command
Typed sessions with the v14 secure defaults.
Typed sessions with the v14 secure defaults.
10-configuration
configuration command
Configuration: one YAML document for the framework and for your own settings, secrets from the environment only, and the merge that makes a partial configuration safe.
Configuration: one YAML document for the framework and for your own settings, secrets from the environment only, and the merge that makes a partial configuration safe.
configuration-worker command
The service's own configuration file, and a background worker the framework starts and stops for you.
The service's own configuration file, and a background worker the framework starts and stops for you.
11-views
templates command
HTML pages from templates, with a shared layout.
HTML pages from templates, with a shared layout.
12-database
pg-crud command
A real database behind the repository seam: kataras/pg, with its errors mapped to HTTP.
A real database behind the repository seam: kataras/pg, with its errors mapped to HTTP.
postgres-mapping command
PostgreSQL error mapping: one blank import turns the driver's errors into 404, 409 and 400.
PostgreSQL error mapping: one blank import turns the driver's errors into 404, 409 and 400.
13-websockets
chat command
A chat room over WebSockets.
A chat room over WebSockets.
14-testing
iris-httptest command
A tasks API tested in main_test.go with the framework's own github.com/kataras/iris/v14/httptest package.
A tasks API tested in main_test.go with the framework's own github.com/kataras/iris/v14/httptest package.
std-httptest command
The same tasks API, tested in main_test.go with nothing but the standard library: net/http/httptest, encoding/json and testing.
The same tasks API, tested in main_test.go with nothing but the standard library: net/http/httptest, encoding/json and testing.
15-production
graceful-shutdown command
Graceful shutdown: what runs when the process is interrupted, in which order, and how long the server waits for in-flight requests.
Graceful shutdown: what runs when the process is interrupted, in which order, and how long the server waits for in-flight requests.
observability command
Observability endpoints: the live process dashboard, the Go profiler, the expvar gauges the dashboard publishes, and per-request cost measurement.
Observability endpoints: the live process dashboard, the Go profiler, the expvar gauges the dashboard publishes, and per-request cost measurement.
serving-and-tls command
Serving: app.Listen for the plain case, app.Run(iris.ServerOptions{...}) when you need TLS, Let's Encrypt or server tuning.
Serving: app.Listen for the plain case, app.Run(iris.ServerOptions{...}) when you need TLS, Let's Encrypt or server tuning.
16-advanced
ai-gateway command
An AI gateway: relaying an upstream provider stream, with failover.
An AI gateway: relaying an upstream provider stream, with failover.
api-graph command
The apigraph controller: an interactive D3.js map of every registered route, mounted behind an admin guard.
The apigraph controller: an interactive D3.js map of every registered route, mounted behind an admin guard.
file-server command
Static file serving with the fileserver controller, hardened with the BlockHidden asset validator.
Static file serving with the fileserver controller, hardened with the BlockHidden asset validator.
multi-app command
Multi-application composition: two independent Iris applications served behind a single listener through apps.Switch.
Multi-application composition: two independent Iris applications served behind a single listener through apps.Switch.
patches command
Global patches: replacing framework defaults through iris.Patches().
Global patches: replacing framework defaults through iris.Patches().
sitemap command
The sitemap controller: /sitemap.xml built from the registered static routes when the application is built.
The sitemap controller: /sitemap.xml built from the registered static routes when the application is built.
std-interop command
Standard library interop: net/http handlers inside Iris, and the Iris application inside a plain http.Server.
Standard library interop: net/http handlers inside Iris, and the Iris application inside a plain http.Server.
typed-context command
Custom typed contexts: handlers written against your own context type through iris.NewContextWrapper.
Custom typed contexts: handlers written against your own context type through iris.NewContextWrapper.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL