blob: ad0e82289db1760922d3d326498ee0161a3b87f7 [file] [log] [blame]
Skyler Greyd7e1acd2024-06-22 14:42:11 +00001# SPDX-FileCopyrightText: 2024 Clicks Codes
2#
3# SPDX-License-Identifier: GPL-3.0-only
4
5{ lib, inputs, ... }:
6{
7 nginx.http = let
8 _directory = listContents: root: {
9 inherit root listContents;
10 _type = "directory";
11 headers = null;
12 };
13 _redirect = permanent: to: {
14 inherit to permanent;
15 _type = "redirect";
16 headers = null;
17 };
18 _reverseProxy = protocol: host: port: {
19 inherit protocol host port;
20 _type = "reverseProxy";
21 headers = null;
22 };
23 in {
24 # Header Manipulation
25 addHeader = name: value: content: {
26 inherit name value content;
27 _type = "header";
28 };
29 unsafeAddCrossOriginHeader = lib.clicks.nginx.http.addHeader "Access-Control-Allow-Origin" "*";
30
31 # Location translatable directives
32
33 directory = _directory true;
34 privateDirectory = _directory false;
35
36 file = path: {
37 inherit path;
38 _type = "file";
39 };
40
41 redirect = _redirect false;
42 redirectPermanent = _redirect true;
43
44 reverseProxySecure = _reverseProxy "https";
45 reverseProxy = _reverseProxy "http";
46
47 status = code: {
48 inherit code;
49 _type = "status";
50 headers = null;
51 };
52 };
53}