class Mux::Router

Overview

The router usually passed as an argument to HTTP::Server.new.

Included Modules

Defined in:

mux.cr

Constant Summary

ALL_METHODS = :all

the placehoder for all methods

Constructors

Instance Method Summary

Constructor Detail

def self.new #

create a new router with no routes.


[View source]

Instance Method Detail

def add_handler(path : String, handler : HTTP::Handler, *, method : String | Symbol = ALL_METHODS) #

add handler using and optionally specify the method

  • path the path to register the handler under
  • handler the handler to register at the given path
  • method the method to filter for, if ALL_METHODS is used, no restrictions are made and all methods will trigger the handler.

[View source]
def add_handler(path : String, *, method : String | Symbol = ALL_METHODS, &handler : HandlerProc) #

add handler using and optionally specify the method

  • path the path to register the handler under
  • handler the handler to register at the given path
  • method the method to filter for, if ALL_METHODS is used, no restrictions are made and all methods will trigger the handler.

[View source]
def call(context) #

implementes HTTP::Handler


[View source]
def connect(path, handler : HTTP::Handler) #

add HTTP connect handler using a hanlder class

  • path the path to register the handler under
  • handler the handler to register at the given path

[View source]
def connect(path, &handler : HandlerProc) #

add HTTP connect handler using a handler proc

  • path the path to register the handler under
  • handler the handler to register at the given path

[View source]
def delete(path, handler : HTTP::Handler) #

add HTTP delete handler using a hanlder class

  • path the path to register the handler under
  • handler the handler to register at the given path

[View source]
def delete(path, &handler : HandlerProc) #

add HTTP delete handler using a handler proc

  • path the path to register the handler under
  • handler the handler to register at the given path

[View source]
def get(path, handler : HTTP::Handler) #

add HTTP get handler using a hanlder class

  • path the path to register the handler under
  • handler the handler to register at the given path

[View source]
def get(path, &handler : HandlerProc) #

add HTTP get handler using a handler proc

  • path the path to register the handler under
  • handler the handler to register at the given path

[View source]
def head(path, handler : HTTP::Handler) #

add HTTP head handler using a hanlder class

  • path the path to register the handler under
  • handler the handler to register at the given path

[View source]
def head(path, &handler : HandlerProc) #

add HTTP head handler using a handler proc

  • path the path to register the handler under
  • handler the handler to register at the given path

[View source]
def options(path, handler : HTTP::Handler) #

add HTTP options handler using a hanlder class

  • path the path to register the handler under
  • handler the handler to register at the given path

[View source]
def options(path, &handler : HandlerProc) #

add HTTP options handler using a handler proc

  • path the path to register the handler under
  • handler the handler to register at the given path

[View source]
def patch(path, handler : HTTP::Handler) #

add HTTP patch handler using a hanlder class

  • path the path to register the handler under
  • handler the handler to register at the given path

[View source]
def patch(path, &handler : HandlerProc) #

add HTTP patch handler using a handler proc

  • path the path to register the handler under
  • handler the handler to register at the given path

[View source]
def post(path, handler : HTTP::Handler) #

add HTTP post handler using a hanlder class

  • path the path to register the handler under
  • handler the handler to register at the given path

[View source]
def post(path, &handler : HandlerProc) #

add HTTP post handler using a handler proc

  • path the path to register the handler under
  • handler the handler to register at the given path

[View source]
def put(path, handler : HTTP::Handler) #

add HTTP put handler using a hanlder class

  • path the path to register the handler under
  • handler the handler to register at the given path

[View source]
def put(path, &handler : HandlerProc) #

add HTTP put handler using a handler proc

  • path the path to register the handler under
  • handler the handler to register at the given path

[View source]
def trace(path, handler : HTTP::Handler) #

add HTTP trace handler using a hanlder class

  • path the path to register the handler under
  • handler the handler to register at the given path

[View source]
def trace(path, &handler : HandlerProc) #

add HTTP trace handler using a handler proc

  • path the path to register the handler under
  • handler the handler to register at the given path

[View source]