aboutsummaryrefslogtreecommitdiff
path: root/lib/http/fs_handler.go
AgeCommit message (Collapse)Author
2026-01-15all: convert license and copyright to use SPDX identifiersShulhan
With help of spdxconv tool [1], we able to bulk update all files license and copyright format to comply with SPDX formats. [1] https://kilabit.info/project/spdxconv/
2026-01-06lib/http: add second return value, statusCode, to FSHandlerShulhan
Non-zero status code indicates that the function already response to the request, and the server will return immediately. Zero status code indicates that the function did not process the request, it is up to server to process the returned node `out`.
2024-03-15lib/http: refactoring FSHandler type to return [*memfs.Node]Shulhan
Changing FSHandler type to return [*memfs.Node], allow the handler to redirect or return custom node. One of the use case is when service Single Page Application (SPA), where route is handled by JavaScript. For example, when user requested "/dashboard" but dashboard directory does not exist, one can write the following handler to return "/index.html", { node, _ = memfs.Get(`/index.html`) return node }
2024-03-02all: move the repository to "git.sr.ht/~shulhan/pakakeh.go"Shulhan
There are several reasons that why we move from github.com. First, related to the name of package. We accidentally name the package with "share" a common word in English that does not reflect the content of repository. By moving to other repository, we can rename it to better and unique name, in this "pakakeh.go". Pakakeh is Minang word for tools, and ".go" suffix indicate that the repository related to Go programming language. Second, supporting open source. The new repository is hosted under sourcehut.org, the founder is known to support open source, and all their services are licensed under AGPL, unlike GitHub that are closed sources. Third, regarding GitHub CoPilot. The GitHub Terms of Service [1], allow any public content that are hosted there granted them to parse the content. On one side, GitHub helps and flourish the open source, but on another side have an issues regarding scraping the copyleft license [2]. [1]: https://docs.github.com/en/site-policy/github-terms/github-terms-of-service#4-license-grant-to-us [2]: https://githubcopilotinvestigation.com
2024-01-24lib/http: update doc to use comment linksShulhan
2022-05-09all: reformat all codes using gofmt 1.19 (the Go tip)Shulhan
2022-03-31lib/http: rewrite ServerOptions FSHandler to handle request in generalShulhan
This changes rename ServerOptions field FSAuthHandler to FSHandler and rewrite their usage. The FSHandler define the function to inspect each GET request to Server MemFS instance. The node parameter contains the requested file inside the memfs. If the handler return true, server will continue processing the node (writing the Node content type, body, and so on). If the handler return false, server stop processing the node and return immediately, which means the function should have already handle writing the header, status code, and/or body.