| Constructor and Description |
|---|
Express()
Default, will bind the server to "localhost"
|
Express(com.sun.net.httpserver.HttpsConfigurator httpsConfigurator)
Default, will bind the server to "localhost"
|
Express(String hostname)
Create an express instance and bind the server to an hostname.
|
Express(String hostname,
com.sun.net.httpserver.HttpsConfigurator httpsConfigurator)
Create an express instance and bind the server to an hostname.
|
| Modifier and Type | Method and Description |
|---|---|
Express |
all(HttpRequestHandler request)
Add an listener for all request methods and contexts.
|
Express |
all(String context,
HttpRequestHandler request)
Adds an handler for a specific context.
|
Express |
all(String context,
String requestMethod,
HttpRequestHandler request)
Adds an handler for a specific context and method.
|
Express |
bind(Object... objects)
Binds a or multiple objects with request-handler methods on this express instance.
|
Express |
delete(String context,
HttpRequestHandler request)
Add an listener for DELETE request's.
|
Object |
get(String key)
Returns the value which was allocated by this key.
|
Express |
get(String context,
HttpRequestHandler request)
Add an listener for GET request's.
|
ConcurrentHashMap<String,HttpRequestHandler> |
getParameterListener() |
boolean |
isSecure() |
void |
listen()
Start the HTTP-Server on port 80.
|
void |
listen(ExpressListener onStart)
Start the HTTP-Server on port 80.
|
void |
listen(ExpressListener onStart,
int port)
Start the HTTP-Server on a specific port.
|
void |
listen(int port)
Start the HTTP-Server on a specific port
This method is asynchronous so be sure to add an listener or keep it in mind!
|
Express |
onParam(String param,
HttpRequestHandler request)
Add a listener which will be called when an url with this parameter is called.
|
Express |
patch(String context,
HttpRequestHandler request)
Add an listener for PATCH request's.
|
Express |
post(String context,
HttpRequestHandler request)
Add an listener for POST request's.
|
Express |
put(String context,
HttpRequestHandler request)
Add an listener for PUT request's.
|
Object |
set(String key,
String val)
Add an key-val pair to the express app, can be used
to store data.
|
void |
setExecutor(Executor executor)
Set an executor service.
|
void |
stop()
Stop express
|
Express |
use(ExpressRouter router)
Add an routing object.
|
Express |
use(HttpRequestHandler middleware)
Add an middleware which will be called before each request-type listener will be fired.
|
Express |
use(String root,
ExpressRouter router)
Add an routing object with an specific root root.
|
Express |
use(String context,
HttpRequestHandler middleware)
Add an middleware which will be called before each request-type listener will be fired.
|
Express |
use(String context,
String requestMethod,
HttpRequestHandler middleware)
Add an middleware which will be called before each request-type listener will be fired.
|
public Express(String hostname)
hostname - The host namepublic Express(com.sun.net.httpserver.HttpsConfigurator httpsConfigurator)
httpsConfigurator - The HttpsConfigurator for httpspublic Express(String hostname, com.sun.net.httpserver.HttpsConfigurator httpsConfigurator)
hostname - The host namehttpsConfigurator - The HttpsConfigurator for httpspublic Express()
public boolean isSecure()
public Express onParam(String param, HttpRequestHandler request)
param - The parameter name.request - An request handler.public ConcurrentHashMap<String,HttpRequestHandler> getParameterListener()
public Object set(String key, String val)
key - The keyval - The valuepublic Object get(String key)
key - The key.public void setExecutor(Executor executor) throws IOException
executor - The new executor.IOException - If the server is currently runningpublic Express use(ExpressRouter router)
router - The router.public Express use(String root, ExpressRouter router)
root - The root path for all request to this router.router - The router.public Express use(HttpRequestHandler middleware)
Routerpublic Express use(String context, HttpRequestHandler middleware)
Routerpublic Express use(String context, String requestMethod, HttpRequestHandler middleware)
Routeruse in interface Routercontext - The context where the middleware should listen for the request handler..requestMethod - And type of request-method eg. GET, POST etc.middleware - An middleware which will be fired if the context matches the request-method- and path.public Express all(HttpRequestHandler request)
Routerpublic Express all(String context, HttpRequestHandler request)
Routerpublic Express all(String context, String requestMethod, HttpRequestHandler request)
Routerpublic Express get(String context, HttpRequestHandler request)
Routerpublic Express post(String context, HttpRequestHandler request)
Routerpublic Express put(String context, HttpRequestHandler request)
Routerpublic Express delete(String context, HttpRequestHandler request)
Routerpublic Express patch(String context, HttpRequestHandler request)
Routerpublic Express bind(Object... objects)
objects - Object with proper request handler methods.public void listen()
public void listen(int port)
port - The port.public void listen(ExpressListener onStart)
onStart - An listener which will be fired after the server is stardet.public void listen(ExpressListener onStart, int port)
onStart - An listener which will be fired after the server is stardet.port - The port.public void stop()
Copyright © 2019. All rights reserved.