Skip to content

Commit ac107d3

Browse files
committed
add getMimeType
1 parent 7a8be5e commit ac107d3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

webui.nim

+7
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ proc getFreePort*(): int =
152152

153153
int bindings.getFreePort()
154154

155+
proc getMimeType*(file: string): string =
156+
## Get the HTTP mime type of a file.
157+
##
158+
## :file: The name of the file (e.g. `foo.png`)
159+
160+
$ bindings.getMimeType(cstring file)
161+
155162
# ------- Impl funcs --------
156163

157164
# --- Event ---

webui/bindings.nim

+4-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ proc getChildProcessId*(window: csize_t): csize_t {.webui, importc: "webui_get_c
400400

401401
proc getPort*(window: csize_t): csize_t {.webui, importc: "webui_get_port", discardable.}
402402
## Get the network port of a running window. This can be useful to determine
403-
## the HTTP link of `webui.js`.
403+
## the HTTP link of `webui.js`.
404404

405405
proc setPort*(window: csize_t; port: csize_t): bool {.webui, importc: "webui_set_port", discardable.}
406406
## Set a custom web-server/websocket network port to be used by WebUI. This
@@ -420,6 +420,9 @@ proc setEventBlocking*(window: csize_t; status: bool) {.webui, importc: "webui_s
420420
## single window. You can use `setConfig(wcUiEventBlocking, ...)` to update
421421
## all windows.
422422

423+
proc getMimeType*(file: cstring): cstring {.webui, importc: "webui_get_mime_type".}
424+
## Get the HTTP mime type of a file.
425+
423426
# -- SSL/TLS -------------------------
424427

425428
proc setTlsCertificate*(certificate_pem: cstring; private_key_pem: cstring): bool {.webui, importc: "webui_set_tls_certificate".}

0 commit comments

Comments
 (0)