Default

http-server

Creates a new HTTP server that listens on the specified address with a 10-second read header timeout.

addr String containing the server address (e.g., "

returns native Go-server object that can handle HTTP requests

http-server ":8080" |type?
; returns native
http-server 8080
; correctly causes error:
; builtin `http-server` requires argument 1 to be: String. 

Go-server//Serve

Starts the HTTP server listening and serving requests on the configured address (blocking call).

server Native Go-server object created by http-server

returns the server object after starting listening, or error if unable to serve

srv: http-server ":8080"
srv .Serve

Go-server//Handle

Registers an HTTP handler for a specific path pattern on the server, accepting string responses, Rye functions, or native Go handlers.

server Native Go-server object

path String URL path to handle (e.g., "/", "/api", "/static")

handler String (simple response), Function (w req -> response), or Native HTTP handler

returns the server object to allow method chaining

srv: http-server ":8080"
srv .Handle "/" "Hello World!"
srv .Handle "/api" fn { w req } { w .Write "API response" }

Go-server-response-writer//Write

Writes string content to the HTTP response body, used within HTTP request handlers to send response data to clients.

writer Native Go-server-response-writer object from HTTP handler

content String content to write to the HTTP response body

returns the response writer object for method chaining

; Inside a handler function { w req }:
; write w "Hello World!"
; w .Write "Response content"

Go-server-response-writer//Set-content-type

Sets the Content-Type header for the HTTP response, determining how the browser interprets the response data.

writer Native Go-server-response-writer object from HTTP handler

contentType String MIME type (e.g., "text/html", "application/json", "image/png")

returns the response writer object for method chaining

; Inside a handler: w .Set-content-type "application/json"
; Inside a handler: w .Set-content-type "text/html"

Go-server-response-writer//Set-header

Sets a custom HTTP header in the response, allowing control over caching, security, and other HTTP behaviors.

writer Native Go-server-response-writer object from HTTP handler

name Word representing the header name (e.g., 'cache-control, 'x-custom-header)

value String value to set for the header

returns the response writer object for method chaining

; Inside a handler: w .Set-header 'cache-control "no-cache"
; Inside a handler: w .Set-header 'x-custom-header "custom-value"

Go-server-response-writer//Write-header

Sets the HTTP status code for the response (must be called before writing response body).

writer Native Go-server-response-writer object from HTTP handler

code Integer HTTP status code (200=OK, 404=Not Found, 500=Internal Server Error, etc.)

returns the response writer object for method chaining

; Inside a handler: w .Write-header 404
; Inside a handler: w .Write-header 200
; Inside a handler: w .Write-header 500

Go-server-request//Query?

Retrieves a query parameter value from the HTTP request URL (e.g., from ?name=value&other=data).

request Native Go-server-request object from HTTP handler

key String name of the query parameter to retrieve

returns string value of the query parameter, or error if key is missing

; Inside a handler with request URL "/api?name=john&age=25":
; equal { req .Query? "name" } "john"
; equal { req .Query? "age" } "25"
; error { req .Query? "missing" }

Go-server-request//Url?

Extracts the URL object from an HTTP request, providing access to path, query parameters, and other URL components.

request Native Go-server-request object from HTTP handler

returns native Go-server-url object containing the parsed request URL

; Inside a handler: url: req .Url?
; equal { url .type? } 'native
; error { "not-request" .Url? }

Go-server-url//Path?

Extracts the path component from a URL object (the part after the domain and before query parameters).

url Native Go-server-url object from request URL

returns string containing the path portion of the URL (without query parameters)

; Inside a handler with request to "/api/users/123":
; url: req .Url?
; equal { url .Path? } "/api/users/123"
; error { "not-url" .Path? }

https-response//Status?

Gets the HTTP status code from a response object.

response native https-response object

returns integer containing the HTTP status code (200, 404, 500, etc.)

https-response//Status-text?

Gets the HTTP status text from a response object.

response native https-response object

returns string containing the HTTP status text (OK, Not Found, Internal Server Error, etc.)