std.net.http.server
struct Field
struct FileSystem
interface Handler
struct HttpError
struct HttpServer
struct MethodRouter
interface Middleware
type Multipart = Multipart
struct MultipartError
struct ParsePathParamError
struct Request
type Response = HttpResponse
struct Router
struct RouterError
delete
pub fn delete(handler: Handler): MethodRouter
[src]
pub fn delete(handler: Handler): MethodRouter {
return MethodRouter { handlers: {Method.Delete: handler} };
}
Create a MethodRouter with a handler for the DELETE method.
delete
pub fn delete(handler: Handler): MethodRouter
[src]
pub fn delete(handler: Handler): MethodRouter {
return MethodRouter { handlers: {Method.Delete: handler} };
}
Create a MethodRouter with a handler for the DELETE method.
Create a MethodRouter with a handler for the DELETE method.
func_handler
pub fn func_handler(func: |(Request)|: Response): Handler
[src]
pub fn func_handler(func: |(Request): Response throws|): Handler {
return FuncHandler { func };
}
Create a new HTTP handler from a function
func_handler
pub fn func_handler(func: |(Request)|: Response): Handler
[src]
pub fn func_handler(func: |(Request): Response throws|): Handler {
return FuncHandler { func };
}
Create a new HTTP handler from a function
Create a new HTTP handler from a function
Example
use std.net.TcpListener;
use std.net.http.server.{Response, func_handler, HttpServer};
fn main() throws {
let handler = func_handler(|req| Response.text("Hello, world!"));
let listener = try TcpListener.bind("127.0.0.1:8080");
let server = HttpServer.new(listener, handler);
try server.serve();
}
get
pub fn get(handler: Handler): MethodRouter
[src]
pub fn get(handler: Handler): MethodRouter {
return MethodRouter { handlers: {Method.Get: handler} };
}
Create a MethodRouter with a handler for the GET method.
get
pub fn get(handler: Handler): MethodRouter
[src]
pub fn get(handler: Handler): MethodRouter {
return MethodRouter { handlers: {Method.Get: handler} };
}
Create a MethodRouter with a handler for the GET method.
Create a MethodRouter with a handler for the GET method.
head
pub fn head(handler: Handler): MethodRouter
[src]
pub fn head(handler: Handler): MethodRouter {
return MethodRouter { handlers: {Method.Head: handler} };
}
Create a MethodRouter with a handler for the HEAD method.
head
pub fn head(handler: Handler): MethodRouter
[src]
pub fn head(handler: Handler): MethodRouter {
return MethodRouter { handlers: {Method.Head: handler} };
}
Create a MethodRouter with a handler for the HEAD method.
Create a MethodRouter with a handler for the HEAD method.
options
pub fn options(handler: Handler): MethodRouter
[src]
pub fn options(handler: Handler): MethodRouter {
return MethodRouter { handlers: {Method.Options: handler} };
}
Create a MethodRouter with a handler for the OPTIONS method.
options
pub fn options(handler: Handler): MethodRouter
[src]
pub fn options(handler: Handler): MethodRouter {
return MethodRouter { handlers: {Method.Options: handler} };
}
Create a MethodRouter with a handler for the OPTIONS method.
Create a MethodRouter with a handler for the OPTIONS method.
patch
pub fn patch(handler: Handler): MethodRouter
[src]
pub fn patch(handler: Handler): MethodRouter {
return MethodRouter { handlers: {Method.Patch: handler} };
}
Create a MethodRouter with a handler for the PATCH method.
patch
pub fn patch(handler: Handler): MethodRouter
[src]
pub fn patch(handler: Handler): MethodRouter {
return MethodRouter { handlers: {Method.Patch: handler} };
}
Create a MethodRouter with a handler for the PATCH method.
Create a MethodRouter with a handler for the PATCH method.
post
pub fn post(handler: Handler): MethodRouter
[src]
pub fn post(handler: Handler): MethodRouter {
return MethodRouter { handlers: {Method.Post: handler} };
}
Create a MethodRouter with a handler for the POST method.
post
pub fn post(handler: Handler): MethodRouter
[src]
pub fn post(handler: Handler): MethodRouter {
return MethodRouter { handlers: {Method.Post: handler} };
}
Create a MethodRouter with a handler for the POST method.
Create a MethodRouter with a handler for the POST method.
put
pub fn put(handler: Handler): MethodRouter
[src]
pub fn put(handler: Handler): MethodRouter {
return MethodRouter { handlers: {Method.Put: handler} };
}
Create a MethodRouter with a handler for the PUT method.
put
pub fn put(handler: Handler): MethodRouter
[src]
pub fn put(handler: Handler): MethodRouter {
return MethodRouter { handlers: {Method.Put: handler} };
}
Create a MethodRouter with a handler for the PUT method.
Create a MethodRouter with a handler for the PUT method.
trace
pub fn trace(handler: Handler): MethodRouter
[src]
pub fn trace(handler: Handler): MethodRouter {
return MethodRouter { handlers: {Method.Trace: handler} };
}
Create a MethodRouter with a handler for the TRACE method.
trace
pub fn trace(handler: Handler): MethodRouter
[src]
pub fn trace(handler: Handler): MethodRouter {
return MethodRouter { handlers: {Method.Trace: handler} };
}
Create a MethodRouter with a handler for the TRACE method.
Create a MethodRouter with a handler for the TRACE method.