module Onyx::HTTP

Overview

HTTP framework.

Defined in:

lib/onyx-http/src/onyx-http.cr
lib/onyx-http/src/onyx-http/error.cr
lib/onyx-http/src/onyx-http/server.cr
onyx/http.cr
onyx/http/spec.cr

Class Method Summary

Macro Summary

Class Method Detail

def self.delete(*args, **nargs, &block : HTTP::Server::Context -> UNDERSCORE) #

Define a DELETE route with block for the singleton .router. See Onyx::HTTP::Router#delete.


[View source]
def self.delete(*args, **nargs) #

Define a DELETE route for the singleton .router. See Onyx::HTTP::Router#delete.


[View source]
def self.get(*args, **nargs, &block : HTTP::Server::Context -> UNDERSCORE) #

Define a GET route with block for the singleton .router. See Onyx::HTTP::Router#get.


[View source]
def self.get(*args, **nargs) #

Define a GET route for the singleton .router. See Onyx::HTTP::Router#get.


[View source]
def self.head(*args, **nargs) #

Define a HEAD route for the singleton .router. See Onyx::HTTP::Router#head.


[View source]
def self.head(*args, **nargs, &block : HTTP::Server::Context -> UNDERSCORE) #

Define a HEAD route with block for the singleton .router. See Onyx::HTTP::Router#head.


[View source]
def self.on(*args, **nargs, &block : Onyx::HTTP::Middleware::Router -> ) #

Draw routes for the singleton .router. See HTTP::Router#draw.


[View source]
def self.options(*args, **nargs, &block : HTTP::Server::Context -> UNDERSCORE) #

Define a OPTIONS route with block for the singleton .router. See Onyx::HTTP::Router#options.


[View source]
def self.options(*args, **nargs) #

Define a OPTIONS route for the singleton .router. See Onyx::HTTP::Router#options.


[View source]
def self.patch(*args, **nargs, &block : HTTP::Server::Context -> UNDERSCORE) #

Define a PATCH route with block for the singleton .router. See Onyx::HTTP::Router#patch.


[View source]
def self.patch(*args, **nargs) #

Define a PATCH route for the singleton .router. See Onyx::HTTP::Router#patch.


[View source]
def self.post(*args, **nargs) #

Define a POST route for the singleton .router. See Onyx::HTTP::Router#post.


[View source]
def self.post(*args, **nargs, &block : HTTP::Server::Context -> UNDERSCORE) #

Define a POST route with block for the singleton .router. See Onyx::HTTP::Router#post.


[View source]
def self.put(*args, **nargs, &block : HTTP::Server::Context -> UNDERSCORE) #

Define a PUT route with block for the singleton .router. See Onyx::HTTP::Router#put.


[View source]
def self.put(*args, **nargs) #

Define a PUT route for the singleton .router. See Onyx::HTTP::Router#put.


[View source]
def self.renderer #

[View source]
def self.renderer=(value) #

[View source]
def self.router #

The singleton HTTP::Router instance.


[View source]
def self.ws(*args, **nargs, &block : ::HTTP::WebSocket, HTTP::Server::Context -> UNDERSCORE) #

Define a "ws://" route with block for the singleton .router. See Onyx::HTTP::Router#ws.


[View source]
def self.ws(*args, **nargs) #

Define a "ws://" route with block for the singleton .router. See Onyx::HTTP::Router#ws.


[View source]

Macro Detail

macro listen(host = "127.0.0.1", port = 3000, reuse_port = false, **handler_options, &block) #

Instantiate an Onyx::HTTP::Server, bind it to the host and port and start listening. Routes for it are defined with singleton Onyx::HTTP.get methods and its siblings.

You can insert your custom code into the &block. At this point, handlers variable will be available.


[View source]
macro render(io, path) #

Render a template at path into io with Kilt.

Onyx::HTTP.render(env.response, "./hello.html.ecr")
# Expands to
Kilt.embed("./hello.html.ecr", env.response)

[View source]