Skip to content

Commit

Permalink
Fix indentation of non-Go code
Browse files Browse the repository at this point in the history
Mostly C and JSON. Since they're hidden in strings and comments, they're
not as obvious. Some even mixed spaces and tabs in between lines.

Use tabs everywhere. Do this only for *.go files for now.
  • Loading branch information
mvdan authored and lonelycode committed Jan 17, 2017
1 parent 0a64ea1 commit 527841b
Show file tree
Hide file tree
Showing 11 changed files with 318 additions and 326 deletions.
48 changes: 24 additions & 24 deletions batch_requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,30 @@ var BatchTestDef = `
var testBatchRequest = `
{
"requests": [
{
"method": "GET",
"headers": {
"test-header-1": "test-1",
"test-header-2": "test-2"
},
"body": "",
"relative_url": "get/?param1=this"
},
{
"method": "POST",
"headers": {},
"body": "TEST BODY",
"relative_url": "post/"
},
{
"method": "PUT",
"headers": {},
"body": "",
"relative_url": "put/"
}
],
"suppress_parallel_execution": true
"requests": [
{
"method": "GET",
"headers": {
"test-header-1": "test-1",
"test-header-2": "test-2"
},
"body": "",
"relative_url": "get/?param1=this"
},
{
"method": "POST",
"headers": {},
"body": "TEST BODY",
"relative_url": "post/"
},
{
"method": "PUT",
"headers": {},
"body": "",
"relative_url": "put/"
}
],
"suppress_parallel_execution": true
}
`
Expand Down
78 changes: 39 additions & 39 deletions coprocess_id_extractor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,21 +253,21 @@ var IdExtractorCoProcessDef = `
}
},
"custom_middleware": {
"pre": [
{
"name": "MyPreMiddleware",
"require_session": false
}
],
"id_extractor": {
"extract_from": "header",
"extract_with": "value",
"extractor_config": {
"header_name": "Authorization"
}
},
"driver": "grpc"
},
"pre": [
{
"name": "MyPreMiddleware",
"require_session": false
}
],
"id_extractor": {
"extract_from": "header",
"extract_with": "value",
"extractor_config": {
"header_name": "Authorization"
}
},
"driver": "grpc"
},
"proxy": {
"listen_path": "/v1",
"target_url": "http://httpbin.org",
Expand Down Expand Up @@ -317,28 +317,28 @@ var ValueExtractorFormSource = `
}
},
"custom_middleware": {
"pre": [
{
"name": "MyPreMiddleware",
"require_session": false
}
],
"id_extractor": {
"extract_from": "form",
"extract_with": "value",
"extractor_config": {
"pre": [
{
"name": "MyPreMiddleware",
"require_session": false
}
],
"id_extractor": {
"extract_from": "form",
"extract_with": "value",
"extractor_config": {
"param_name": "auth"
}
},
"driver": "grpc"
},
}
},
"driver": "grpc"
},
"proxy": {
"listen_path": "/v1",
"target_url": "http://httpbin.org",
"strip_listen_path": false
}
}
`
`

var RegexExtractorDef = `
Expand Down Expand Up @@ -382,16 +382,16 @@ var RegexExtractorDef = `
},
"custom_middleware": {
"id_extractor": {
"extract_from": "header",
"extract_with": "regex",
"extractor_config": {
"header_name": "Authorization",
"regex_expression": "[^\\\\-]+",
"extract_from": "header",
"extract_with": "regex",
"extractor_config": {
"header_name": "Authorization",
"regex_expression": "[^\\\\-]+",
"regex_match_index": 1
}
},
"driver": "grpc"
},
}
},
"driver": "grpc"
},
"proxy": {
"listen_path": "/v1",
"target_url": "http://httpbin.org",
Expand Down
28 changes: 14 additions & 14 deletions coprocess_lua.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,37 @@ static void LoadMiddleware(char* middleware_file, char* middleware_contents) {
}
static void LoadMiddlewareIntoState(lua_State* L, char* middleware_name, char* middleware_contents) {
luaL_dostring(L, middleware_contents);
luaL_dostring(L, middleware_contents);
}
static struct CoProcessMessage* LuaDispatchHook(struct CoProcessMessage* object) {
struct CoProcessMessage* outputObject = malloc(sizeof *outputObject);
struct CoProcessMessage* outputObject = malloc(sizeof *outputObject);
lua_State *L = luaL_newstate();
lua_State *L = luaL_newstate();
luaL_openlibs(L);
// luaL_dofile(L, "coprocess/lua/tyk/core.lua");
LoadCachedModules(L);
luaL_openlibs(L);
// luaL_dofile(L, "coprocess/lua/tyk/core.lua");
LoadCachedModules(L);
LoadCachedMiddleware(L);
lua_getglobal(L, "dispatch");
LoadCachedMiddleware(L);
lua_getglobal(L, "dispatch");
lua_pushlstring(L, object->p_data, object->length);
int call_result = lua_pcall(L, 1, 2, 0);
lua_pushlstring(L, object->p_data, object->length);
int call_result = lua_pcall(L, 1, 2, 0);
size_t lua_output_length = lua_tointeger(L, -1);
const char* lua_output_data = lua_tolstring(L, 0, &lua_output_length);
char* output = malloc(lua_output_length);
memmove(output, lua_output_data, lua_output_length);
lua_close(L);
lua_close(L);
outputObject->p_data = (void*)output;
outputObject->length = lua_output_length;
outputObject->p_data = (void*)output;
outputObject->length = lua_output_length;
return outputObject;
return outputObject;
}
static void LuaDispatchEvent(char* event_json) {
Expand Down
82 changes: 41 additions & 41 deletions coprocess_python.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,42 @@ package main
PyGILState_STATE gilState;
static int Python_Init() {
CoProcessLog( sdsnew("Initializing interpreter, Py_Initialize()"), "info");
Py_Initialize();
CoProcessLog( sdsnew("Initializing interpreter, Py_Initialize()"), "info");
Py_Initialize();
gilState = PyGILState_Ensure();
PyEval_InitThreads();
// This exposes the Cython interface as "gateway"
PyInit_gateway();
return Py_IsInitialized();
return Py_IsInitialized();
}
static int Python_LoadDispatcher() {
PyObject *module_name = PyUnicode_FromString( dispatcher_module_name );
dispatcher_module = PyImport_Import( module_name );
PyObject *module_name = PyUnicode_FromString( dispatcher_module_name );
dispatcher_module = PyImport_Import( module_name );
Py_DECREF(module_name);
if( dispatcher_module == NULL ) {
PyErr_Print();
return -1;
}
if( dispatcher_module == NULL ) {
PyErr_Print();
return -1;
}
dispatcher_module_dict = PyModule_GetDict(dispatcher_module);
dispatcher_module_dict = PyModule_GetDict(dispatcher_module);
if( dispatcher_module_dict == NULL ) {
PyErr_Print();
return -1;
}
if( dispatcher_module_dict == NULL ) {
PyErr_Print();
return -1;
}
dispatcher_class = PyDict_GetItemString(dispatcher_module_dict, dispatcher_class_name);
dispatcher_class = PyDict_GetItemString(dispatcher_module_dict, dispatcher_class_name);
if( dispatcher_class == NULL ) {
PyErr_Print();
return -1;
}
if( dispatcher_class == NULL ) {
PyErr_Print();
return -1;
}
return 0;
return 0;
}
static void Python_ReloadDispatcher() {
Expand All @@ -77,7 +77,7 @@ static void Python_ReloadDispatcher() {
}
static void Python_HandleMiddlewareCache(char* bundle_path) {
gilState = PyGILState_Ensure();
gilState = PyGILState_Ensure();
if( PyCallable_Check(dispatcher_load_bundle) ) {
PyObject* load_bundle_args = PyTuple_Pack( 1, PyUnicode_FromString(bundle_path) );
PyObject_CallObject( dispatcher_load_bundle, load_bundle_args );
Expand All @@ -86,23 +86,23 @@ static void Python_HandleMiddlewareCache(char* bundle_path) {
}
static int Python_NewDispatcher(char* middleware_path, char* event_handler_path, char* bundle_paths) {
if( PyCallable_Check(dispatcher_class) ) {
dispatcher_args = PyTuple_Pack( 3, PyUnicode_FromString(middleware_path), PyUnicode_FromString(event_handler_path), PyUnicode_FromString(bundle_paths) );
dispatcher = PyObject_CallObject( dispatcher_class, dispatcher_args );
if( PyCallable_Check(dispatcher_class) ) {
dispatcher_args = PyTuple_Pack( 3, PyUnicode_FromString(middleware_path), PyUnicode_FromString(event_handler_path), PyUnicode_FromString(bundle_paths) );
dispatcher = PyObject_CallObject( dispatcher_class, dispatcher_args );
Py_DECREF(dispatcher_args);
if( dispatcher == NULL) {
PyErr_Print();
return -1;
}
} else {
PyErr_Print();
return -1;
}
if( dispatcher == NULL) {
PyErr_Print();
return -1;
}
} else {
PyErr_Print();
return -1;
}
dispatcher_hook_name = PyUnicode_FromString( hook_name );
dispatcher_hook = PyObject_GetAttr(dispatcher, dispatcher_hook_name);
dispatcher_hook_name = PyUnicode_FromString( hook_name );
dispatcher_hook = PyObject_GetAttr(dispatcher, dispatcher_hook_name);
dispatch_event_name = PyUnicode_FromString( dispatch_event_name_s );
dispatch_event = PyObject_GetAttr(dispatcher, dispatch_event_name );
Expand All @@ -113,17 +113,17 @@ static int Python_NewDispatcher(char* middleware_path, char* event_handler_path,
Py_DECREF(dispatcher_hook_name);
Py_DECREF(dispatch_event_name);
if( dispatcher_hook == NULL ) {
PyErr_Print();
return -1;
}
if( dispatcher_hook == NULL ) {
PyErr_Print();
return -1;
}
return 0;
return 0;
}
static void Python_SetEnv(char* python_path) {
CoProcessLog( sdscatprintf(sdsempty(), "Setting PYTHONPATH to '%s'", python_path), "info");
setenv("PYTHONPATH", python_path, 1 );
CoProcessLog( sdscatprintf(sdsempty(), "Setting PYTHONPATH to '%s'", python_path), "info");
setenv("PYTHONPATH", python_path, 1 );
}
static struct CoProcessMessage* Python_DispatchHook(struct CoProcessMessage* object) {
Expand Down
30 changes: 15 additions & 15 deletions coprocess_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,15 +350,15 @@ var basicCoProcessDef = `
]
}
},
"custom_middleware": {
"pre": [
{
"name": "MyPreMiddleware",
"require_session": false
}
],
"driver": "python"
},
"custom_middleware": {
"pre": [
{
"name": "MyPreMiddleware",
"require_session": false
}
],
"driver": "python"
},
"proxy": {
"listen_path": "/v1",
"target_url": "http://httpbin.org",
Expand Down Expand Up @@ -409,12 +409,12 @@ var protectedCoProcessDef = `
]
}
},
"custom_middleware": {
"auth_check": {
"name": "TestAuthCheck"
},
"driver": "python"
},
"custom_middleware": {
"auth_check": {
"name": "TestAuthCheck"
},
"driver": "python"
},
"proxy": {
"listen_path": "/v1",
"target_url": "http://httpbin.org",
Expand Down
Loading

0 comments on commit 527841b

Please sign in to comment.