diff --git a/collects/web-server/scribblings/misc-util.scrbl b/collects/web-server/scribblings/misc-util.scrbl new file mode 100644 index 0000000000..17bdec3a45 --- /dev/null +++ b/collects/web-server/scribblings/misc-util.scrbl @@ -0,0 +1,66 @@ +#lang scribble/doc +@(require "web-server.rkt") + +@title[#:tag "misc-util" #:style 'toc]{Miscellaneous Utilities} + +@(require (for-label web-server/private/util + racket/path)) + +@defmodule[web-server/private/util] + +@defproc[(bytes-ci=? [b1 bytes?] [b2 bytes?]) boolean?]{ + Compares two bytes case insensitively. +} + +@defproc[(url-replace-path [proc ((listof path/param?) . -> . (listof path/param?))] + [u url?]) + url?]{ + Replaces the URL path of @racket[u] with @racket[proc] of the former path. +} + +@defproc[(url-path->string [url-path (listof path/param?)]) + string?]{ + Formats @racket[url-path] as a string with @racket["/"] as a delimiter + and no params. +} + +@defproc[(explode-path* [p path-string?]) + (listof path-piece?)]{ + Like @racket[normalize-path], but does not resolve symlinks. +} + +@defproc[(path-without-base [base path-string?] + [p path-string?]) + (listof path-piece?)]{ + Returns, as a list, the portion of @racket[p] after @racket[base], + assuming @racket[base] is a prefix of @racket[p]. +} + +@defproc[(directory-part [p path-string?]) + path?]{ + Returns the directory part of @racket[p], returning @racket[(current-directory)] + if it is relative. +} + +@defproc[(build-path-unless-absolute [base path-string?] + [p path-string?]) + path?]{ + Prepends @racket[base] to @racket[p], unless @racket[p] is absolute. +} + +@defproc[(strip-prefix-ups [p (listof path-piece?)]) + (listof path-piece?)]{ + Removes all the prefix @racket[".."]s from @racket[p]. +} + +@defproc[(network-error [s symbol?] + [fmt string?] + [v any/c] ...) + void]{ + Like @racket[error], but throws a @racket[exn:fail:network]. +} + +@defproc[(exn->string [exn (or/c exn? any/c)]) + string?]{ + Formats @racket[exn] with @racket[(error-display-handler)] as a string. +} diff --git a/collects/web-server/scribblings/private.scrbl b/collects/web-server/scribblings/private.scrbl index c3e7f3815e..57cd7af289 100644 --- a/collects/web-server/scribblings/private.scrbl +++ b/collects/web-server/scribblings/private.scrbl @@ -17,3 +17,4 @@ Some of these are documented here. @include-section["mod-map.scrbl"] @include-section["url-param.scrbl"] @include-section["gzip.scrbl"] +@include-section["misc-util.scrbl"]