aboutsummaryrefslogtreecommitdiff
path: root/server.go
AgeCommit message (Collapse)Author
2026-02-11cmd/ciigo: add option to set base path and shutdown idle durationShulhan
The `-base-path` option set the URL prefix for serving HTTP request. This allow serving the content under the prefix other than "/". The `-shutdown-idle` option set the duration when server will stop accepting new connections and shutting down. This option can be helpful to reduce the resources on local environment.
2026-02-07all: embed struct [lib/http.ServerOptions] directly to [ServeOptions]Shulhan
At this point, all of the fields in the struct ServeOptions is the same with [lib/http.ServerOptions] except IsDevelopment and ConvertOptions. For field IsDevelopment we keep in the struct. For field ConvertOptions we remove it and let the caller pass it on Serve function or InitHTTPServer method.
2026-02-05server: enable ServerOptions HandleFS by defaultShulhan
This allow request for .adoc/.md get redirected to .html in production environment, as we have in https://golang-id.org/proposal/ .
2026-02-05all: redirect request for .adoc or .md to the HTML fileShulhan
During serve, onGet method, if the node does not exist and the request path end with .adoc or .md, redirect the client to the .html location with status 303 (StatusSeeOther).
2026-02-02all: add field Listener to ServeOptionsShulhan
The field Listener allow passing [net.Listener] instance for accepting HTTP connection. One of the use case is to activate the ciigo serve using systemd.socket(5).
2026-01-24all: embed CSS and index HTML template using memfsShulhan
Previously, with direct embed, every time we change the CSS or index template, we need to restart the "ciigo serve" command. Using memfs make us easy to update and see the changes directly, without restarting the server.
2026-01-16go.mod: update pakakeh.go to v0.60.3-0.20260115103415-806359d5462fShulhan
This update have changes on [lib/http.FSHandler] that return second parameter, status code.
2025-02-03server: fix log prefix on InitHTTPServer methodShulhan
2025-01-07all: auto convert markup when HTTP client request GET to HTML fileShulhan
In development mode, where [ServeOptions.IsDevelopment] is set to true or when running "ciigo serve", the ciigo HTTP server will check if the new markup file is newer than HTML file when user press refresh or reload on the browser. If its newer, it will convert the markup file and return the new content of HTML file.
2024-09-28all: introduce new type CiigoShulhan
The Ciigo type provides customizable and reusable instance of ciigo for embedding, converting, and/or serving HTTP server. This type is introduced so one can add HTTP handler or endpoint along with serving the files.
2024-05-12all: initialize memfs using NewShulhan
When memfs not initialized using New, the [memfs.MemFS.PathNodes] will be nil. This cause any Get on new file will return 404.
2024-03-21all: add server option to automatically generate index HTMLShulhan
If the requested path is directory and no "index.html" file exist in that directory, ciigo server will render list of files as "index.html" automatically.
2024-03-15go.mod: update module "pakakeh.go" to tipShulhan
2024-03-05all: replace module "share" with "pakakeh.go"Shulhan
2023-12-10all: fix all warnings reported by linter reviveShulhan
Unfortunately, this breaks some API and exported fields, but its better than creating revive.toml file to add an exception. Some breaking changes, * Field [ConvertOptions.HtmlTemplate] become [ConvertOptions.HTMLTemplate] * Method [Converter.SetHtmlTemplateFile] become [Converter.SetHTMLTemplateFile] * Method [Converter.ToHtmlFile] become [Converter.ToHTMLFile]
2023-11-09all: add method to stop watcherShulhan
With the latest update on lib/memfs, we can stop the watcher internally.
2023-10-13all: print log message with log packageShulhan
This is to provide the timestamp to each log output.
2023-06-01all: add prefix "http://" when printing serve addressShulhan
This is to allow user to click the address in terminal that support it.
2022-08-07all: fix HTML template loaded during Serve on non-developmentShulhan
The HTML template in the ServeOptions should not read when ciigo.Serve running on non-development environment.
2022-08-06all: cleaning up codesShulhan
2022-08-01all: clean up codesShulhan
Replace any usage of ":=" with explicit variable declaration for better types clarity.
2022-08-01all: export internal htmlGenerator as ConverterShulhan
The purpose of Converter is to provide a single, reusable converter for AsciiDoc file or content.
2022-07-09all: update share module to v0.39.1-0.20220709072157-a39d5d2246f8Shulhan
This changes update the embedded Go file on cmd/ciigo-example and rename field Development on MemFS Options.
2022-05-19all: reformat all files using latest goimportsShulhan
While at it, replace any use of ioutil with os/io package.
2022-03-27all: set the field Development to true if MemFS is not set on newServerShulhan
2022-03-04all: re-licensing ciigo under GPL-3.0 or laterShulhan
See https://kilabit.info/journal/2022/gpl/ for more information.
2022-02-19all: fix adoc files not re-converted when template file changesShulhan
In commit 06d03f6afe37 we skip converting files if the generated HTML is newer than adoc file. This cause an issue where the template file changes during Watch or Serve, but the HTML files is not regenerated.
2022-02-19all: add option IsDevelopment to ServeOptionsShulhan
If the IsDevelopment option set to true, the serve function will serve the root directory directly and watch all asciidoc files for changes and convert it. This is like running Watch, Convert and Serve at the same time.
2022-01-10go.mod: update to latest share moduleShulhan
2021-10-17all: fix empty fileMarkups on watcherShulhan
Previously, when user call ciigo.Watch(), and the markup file changes, the onChangeFileMarkup method will print an error "xyz not found" which cause the markup file not converted. This is caused by watcher.fileMarkups is empty. This changes fix this issue by initializing the fileMarkups field using listFileMarkups, so the next callback to onChangeFileMarkup can detect the changed file and convert it.
2021-10-10all: rename type fileHTML to fileHtmlShulhan
2021-07-09go.mod: upgrade share module to v0.28.1-0.20210709045022-0cd813b8ae8aShulhan
This upgrade affect the Server due to field Memfs has been removed from lib/http.Server.
2021-04-03all: add option to exclude certain paths using regular expressionShulhan
The ConvertOptions now has the Exclude field that can contains regular expression. If the Exclude is not empty, it will be compiled and use in Convert, Generate, Watch, and Serve; to ignore specific paths being scanned.
2021-04-03all: change the Serve signature to ServeOptionsShulhan
Previously, we pass four parameters to Serve function: the instance to memfs.MemFS, the root directory, the address to listen, and path to HTML template. In case we need to add new parameter in the future, the Serve function signature will changes and this is not good for consumer of API. This commit changes the Serve function parameters to ServeOptions so we can add optional parameter in the future without changes to its signature.
2021-03-04all: update with latest share moduleShulhan
2021-02-21all: return error instead of call log.Fatal on non main packagesShulhan
The library, non-main packages, should never call Fatal or panic, its up to the main package or the caller on how to handle it. While at it, fix the returned error to use log prefix and the error value, remove the "ciigo: " prefix.
2021-02-21all: rewrite to use the watcherShulhan
Now that we have the watcher which task are to watch the asciidoc files and template files, we can use it in server to minimize duplicate code. This changes refactoring the htmlGenerator to initialize the HTML template from internal or memfs, so the caller did not need to check by itself.
2021-02-21all: add the fileHTML type to fileMarkup typeShulhan
This is to minimize recreating the fileHTML for the same fileMarkup, and to simplify operation that require fileMarkup and fileHTML at the same time.
2021-01-10all: refactoring due to change on memfs packageShulhan
This changes affect exported function Generate and Serve. Previously, the Generate() function accept three options: dir, out, and htmlTemplate; this commit changes the parameter into single struct Options with two additional options: GenPackageName and GenVarName. The GenPackageName allow to set the package name in Go generate source code, default to "main" if not set. The GenVarName set the instance of memfs.MemFS where the embedded files will be stored. On the Serve() function, we add parameter to pass the instance of memfs.MemFS (the one that passed on GenVarName).
2020-06-27server: fix html template not being watched on changeShulhan
2020-05-01all: simplify serving content using function ServeShulhan
Previously to serve the generated content we call two fucntions: NewServer() and Server.Start(). This changes unexported the internal server, and expose only the Serve() function with the same parameter as NewServer().
2020-05-01all: embed the HTML template and the stylesheetShulhan
The parameter for template either in Convert or Generate functions or in CLI now become pure optional, not default to "templates/html.tmpl" anymore. This will minimize steps for user to setup or run the library or program.
2020-03-30go.mod: update share moduleShulhan
2020-03-24all: rename markupFile to fileMarkupShulhan
This is to make it consistent with fileHTML.
2020-02-14all: fix and suppress linter warningsShulhan
2019-09-27all: include the template file in generated Go codeShulhan
The internal search template require the HTML generator to be initialized with HTML template that provide when running "go generate". Without the template, the internal search function will not work.
2019-09-25all: implement search functionalityShulhan
The search function is available through internal API "/_internal/search" with single parameter "q" that contains one or more words to search.
2019-08-14cmd/ciigo: a CLI to convert, generate, and serve markup filesShulhan
Here are the usage of CLI, ciigo [-template <file>] convert <dir> Scan the "dir" recursively to find markup files (.adoc or .md) and convert them into HTML files. The template "file" is optional, default to "templates/html.tmpl" in the current directory. ciigo [-template <file>] [-out <file>] generate <dir> Convert all markup files inside directory "dir" recursively and then embed them into ".go" source file. The output file is optional, default to "ciigo_static.go" in current directory. ciigo [-template <file>] [-address <ip:port>] serve <dir> Serve all files inside directory "dir" using HTTP server, watch changes on markup files and convert them to HTML files automatically. If the address is not set, its default to ":8080".
2019-08-05server: add parameter to change the root directoryShulhan
Previously the default root directory to be served by ciigo is "content" directory inside the top directory. This change allow ciigo to serve any directory pointed by first parameter in NewServer(), and if its empty default to "content".
2019-08-05all: add support for markdown markup languageShulhan
Due to the popularity of markdown format, we decide to support converting markdown file in ciigo. While at it ignore all files or directories that start with dot, which are hidden file in unix-like system.