mirror of
https://github.com/jorisvink/kore
synced 2025-03-09 12:39:01 -04:00
Python API domain improvement.
Add redirect() method to add a redirect on a domain much like in the Kore configuration file. eg: domain.redirect("^/account/(.*)$", 301, "https://site/account/$1")
This commit is contained in:
parent
a68a53c59e
commit
66e893f1d4
@ -231,10 +231,12 @@ struct pydomain {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static PyObject *pydomain_filemaps(struct pydomain *, PyObject *);
|
static PyObject *pydomain_filemaps(struct pydomain *, PyObject *);
|
||||||
|
static PyObject *pydomain_redirect(struct pydomain *, PyObject *);
|
||||||
static PyObject *pydomain_route(struct pydomain *, PyObject *, PyObject *);
|
static PyObject *pydomain_route(struct pydomain *, PyObject *, PyObject *);
|
||||||
|
|
||||||
static PyMethodDef pydomain_methods[] = {
|
static PyMethodDef pydomain_methods[] = {
|
||||||
METHOD("filemaps", pydomain_filemaps, METH_VARARGS),
|
METHOD("filemaps", pydomain_filemaps, METH_VARARGS),
|
||||||
|
METHOD("redirect", pydomain_redirect, METH_VARARGS),
|
||||||
METHOD("route", pydomain_route, METH_VARARGS | METH_KEYWORDS),
|
METHOD("route", pydomain_route, METH_VARARGS | METH_KEYWORDS),
|
||||||
METHOD(NULL, NULL, -1)
|
METHOD(NULL, NULL, -1)
|
||||||
};
|
};
|
||||||
|
17
src/python.c
17
src/python.c
@ -5616,6 +5616,23 @@ pydomain_filemaps(struct pydomain *domain, PyObject *args)
|
|||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
pydomain_redirect(struct pydomain *domain, PyObject *args)
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
const char *src, *dst;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args, "sis", &src, &status, &dst))
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
if (!http_redirect_add(domain->config, src, status, dst)) {
|
||||||
|
fatal("failed to add redirect '%s' on '%s'",
|
||||||
|
src, domain->config->domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
pydomain_route(struct pydomain *domain, PyObject *args, PyObject *kwargs)
|
pydomain_route(struct pydomain *domain, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user