{"id":15356653,"url":"https://github.com/shenruisi/prengine","last_synced_at":"2025-03-15T06:45:20.732Z","repository":{"id":62457488,"uuid":"80330601","full_name":"shenruisi/prengine","owner":"shenruisi","description":"一种用来帮助客户端实现更好的路由解决方案的rewrite引擎（mobile router）","archived":false,"fork":false,"pushed_at":"2018-01-16T08:09:17.000Z","size":397,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-21T21:47:58.042Z","etag":null,"topics":["ios","rewrite","router"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shenruisi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-29T05:36:54.000Z","updated_at":"2024-12-22T12:19:42.000Z","dependencies_parsed_at":"2022-11-02T00:31:36.542Z","dependency_job_id":null,"html_url":"https://github.com/shenruisi/prengine","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shenruisi%2Fprengine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shenruisi%2Fprengine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shenruisi%2Fprengine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shenruisi%2Fprengine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shenruisi","download_url":"https://codeload.github.com/shenruisi/prengine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243695537,"owners_count":20332626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","rewrite","router"],"created_at":"2024-10-01T12:29:29.870Z","updated_at":"2025-03-15T06:45:20.706Z","avatar_url":"https://github.com/shenruisi.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# prengine\n[![Contact me](https://img.shields.io/badge/contact-me-orange.svg)](mailto:tigris.shin@gmail.com)\n[![Build Status](https://travis-ci.org/shenruisi/prengine.svg?branch=master)](https://travis-ci.org/shenruisi/prengine)\n[![GitHub license](https://img.shields.io/badge/license-BSD-blue.svg?style=flat)](https://github.com/shenruisi/prengine/blob/master/LICENSE)\n\n**Poor Router Engine** 一种用来帮助客户端实现更好的路由解决方案的rewrite引擎，可以用于客户端页面路由，模块解耦。\n\n## 设计\n通过`prengine`，你可以使用部分`nginx`语法来描写配置文件，`prengine`将会解析输入的URI，并根\n据输入URI进行匹配，应用条件表达式，最后输出替换后的结果和规则。剩余的你可以使用Objective-C,Swift,\n或是Java将`prengine`在iOS或是Android平台上进行封装。\n\n## 示例\n\n* [配置文件](https://github.com/shenruisi/prengine/blob/master/sample/sample.conf) - prengine所使用的配置文件格式\n\n#### 执行示例代码\n\n```\ng++ ../package/prengine_val.cpp ../package/cond_ast.cpp ../package/prengine.cpp  main.cpp\n./a.out\n```\n\n## 安装\n\n#### 直接安装\n\n```\n拷贝package/目录下的prengine.h, prengine.cpp, prengine_val.h, prengine_val.cpp, cond_ast.h,\ncond_ast.cpp到目标目录即可。\n```\n\n#### 获取.a文件\n\n```\n进入package/目录 运行make 在bin/目录下获取.a文件。\n```\n\n#### 获取ios平台.a文件\n\n```\n进入package/目录 运行make platform=ios 在bin/目录下获取.a文件。\n```\n\n## 使用\n1.`include \"prengine.h\"`\n\n2.调用`PRFILE* pr_creat(char *cnt, VAL_HANDlER valhandler)`来装载config文件\n\n3.调用`PRREWRITE* pr_rewrite_matched_creat(PRFILE *f,const char *uri)` 传入`PRFILE`句柄和需要转化的`URI`,得到相应的`PRREWRITE`对象。\n\n4.通过`const char *pr_getserver(PRREWRITE *)`,`const char *pr_getscheme(PRREWRITE *)`,`const char *pr_getoutval(PRREWRITE *)`,`const char *pr_getrule(PRREWRITE *)`\n来获取`PRREWRITE`对象的不同属性。\n\n5.调用`void pr_rewritefree(PRREWRITE *)`释放`PRREWRITE`对象。\n\n#### 变量注入\n\n如何在config文件中使用自定义变量（eg. 在config中使用`$test`）？\n\n```c++\npr_id your_handler(const char *vname){\n  if(strcmp(vname, \"test\") == 0){\n      return pr_yes();\n  }\n  return pr_undefined();\n}\n\npr_creat(f /*PRFILE句柄*/,your_handler);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshenruisi%2Fprengine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshenruisi%2Fprengine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshenruisi%2Fprengine/lists"}