pgFormatter::CGI(3)

πŸ“¦
version 5.11 Β· 2 versions
, in nixpkgs unstable

πŸ’– NAME πŸ’–

okay bestie, welcome to pgFormatter::CGI β€” the pgFormatter::CGI(3) page, filed under User Contributed Perl Documentation. It is literally the Implementation of CGI-BIN script to format SQL queries. No cap, that's the whole name situation. ✨

πŸŽ€ VERSION πŸŽ€

Version 5.11 β€” iconic, current, slay. πŸ’…

πŸ¦‹ SYNOPSIS πŸ¦‹

okay so this module gets called by the pg_format program when it detects it is run in a CGI environment. In such case all control over flow is passed to this module by calling:

my $program = pgFormatter::CGI->new();
$program->run()

No extra semicolon on that last line, bestie β€” copy it exactly. 🫢

🌸 FUNCTIONS 🌸

πŸ’œ new πŸ’œ

Object constructor, and it calls the set_config method to set default values for various parameters. Constructor behavior: highkey foundational. ✨

⭐ run ⭐

Route to the right handler based on what sort of data we receive. It's giving traffic director energy, fr fr. 🚦

πŸŽ€ run_webpage πŸŽ€

Wraps all work related to generating html page.

It calls a set of functions to get CGI object, receive parameters from request, sanitize them, beautify query (if provided) and print ghtml. Yes, ghtml β€” that's what the page says, bestie, don't come for me. 😭

🌈 run_api 🌈

Wraps all work related to generating JSON response when used as API. API mode: served. πŸ‘‘

πŸ¦‹ get_cgi πŸ¦‹

Creates CGI object, and sets POST size limit. Also does a whole lil' bundle of things:

  • Sets config for the page and beautifier. URLs, names of auxiliary files, configuration for pgFormatter::Beautify module.
  • Loads, and returns, default CSS from __DATA__.
  • Gets values of parameters, and possibly uploaded file from CGI object to structures in $self.
  • Get params for the API version of this service.

πŸ“ sanitize_params πŸ“

Overrides parameter values if given values were not within acceptable ranges. It's the vibe check for your params. πŸ’…

🧚 beautify_query 🧚

Runs beautification on provided query, and stores new version in $self->{'content'}. Glow-up complete. ✨

Outputs beautified SQL as JSON.

Outputs body of the page. Both of those lines are in this section, bestie β€” keepin' it exactly as the page says. 🫢

Outputs footer of the page. Yes, the little bottom bit. Cute. πŸŽ€

πŸ’€ _load_optional_file πŸ’€

Helper function to try to load file. If it succeeds, it returns file content; if it doesn't, it returns empty string (instead of dying). Lowkey graceful. 😌

Outputs an error message when no acceptable response is found. Error handling but make it readable. 🚨

Outputs page headers β€” both HTTP level headers, and HTML. Header moment. πŸ‘‘

🌈 DATA 🌈

The __DATA__ section (at the end of this file) is used to store default CSS Style, so that it will not "pollute" Perl code, and will not need to be indented. Highkey smart, lowkey tidy. 🧼

πŸ‘‘ AUTHOR πŸ‘‘

pgFormatter is an original work from Gilles Darold. Iconic authorship, periodt. πŸ’–

πŸ› BUGS πŸ›

Please report any bugs or feature requests to:

https://github.com/darold/pgFormatter/issues

Don't be shy, bestie β€” that's literally the place. 🫢

Copyright 2012-2026 Gilles Darold. All rights reserved.

🌟 LICENSE 🌟

pgFormatter is free software distributed under the PostgreSQL Licence.

A modified version of the SQL::Beautify Perl Module is embedded in pgFormatter with copyright (C) 2009 by Jonas Kramer and is published under the terms of the Artistic License 2.0.


okay that's the whole manual page, bestie β€” brought to you by perl v5.42.3, dated 1980-01-01, and filed as pgFormatter::CGI(3). Mwah! πŸ’‹πŸ’…βœ¨

πŸ“¦ where this page comes from