Repository navigation
v0.5.0
Added
- OpenAPI documents.
openapi.New(openapi.Options{...})inInstalledAppsserves an OpenAPI 3.1 document of every included route at/openapi.json(opt-in: nothing is served otherwise).openapi.Devis the same app served only whenTANGO_OPENAPI=1, so a deployed process exposes nothing unless it sets the variable. Each route is listed with its method, path, path parameters, name and a tag from its prefix.tango.Doc(tango.RouteDoc{...})adds a summary, a request body, query parameters, responses and a bearer requirement, with schemas reflected from Go types (encoding/jsontags, nested and recursive types,varchar=nasmaxLength); a type can name its schema withSchemaName().tango checkfails and names a route whose documented types cannot be described. TheaccountsJSON endpoints document themselves; the admin's pages and the cookie-flow pages are hidden from the document.RouteRegistry.Describedandtango.DescribedRouteexpose the route table to tools.tango newprojectnow leaves a comment inproject/project.gosaying where to add it. See OpenAPI documentation. tango openapi [-o file]prints or writes the document (the new-tango-openapiapp-side flag, handled byDispatchFlags;DumpOpenAPI,OpenAPIProviderandErrNoOpenAPI). The output is the same bytes on every run, and a failed run leaves an existing file untouched.- Swagger UI.
openapi.Options{UI: swaggerui.New()}adds a browsable page at/docs/from Swagger UI 5.17.14 embedded in the binary (Apache-2.0; no network request). It is the separate packageopenapi/swaggeruiand adds about 1.7 MB to a binary that imports it.
Changed
-
Database connections are reused under load.
database/sqlkeeps only 2 idle connections, so a server handling more than 2 requests at once closed and reopened a database connection on almost every request (measured: about 10,900 PostgreSQL sessions opened in one 15-second run of single-pet reads).ServeContextnow raises the idle limit to 32 unless your app bounded the pool withSetMaxOpenConns.tango.WithDBPool(tango.DBPool{...})sets the limits explicitly;tango.WithDBPool(tango.DBPool{})restores the previous behavior. The number of open connections is unchanged (unlimited). -
Foreign keys are not indexed unless you say so (guidance). A
fk=column is not indexed by itself, so filtering or joining on it scans the table (measured:liston a 10,000-row table ran at about 1,300 requests a second without the index and about 3,200 with it). Writetango:"fk=Category,index"on foreign keys you filter or join on. Indexing foreign keys by default, as Django does, is planned for a later minor release; this entry is the notice.
Fixed
- The admin no longer comes up silently empty. The admin builds its pages when it is installed, so a model registered by an app listed after
admin.Newnever appeared in it.tango check(and-check) now fails and names those models, thetango newprojectscaffold says to add apps aboveadmin.New, andtango newapprepeats it when the project installs the admin. Moveadmin.Newafter your apps.