Giter VIP home page Giter VIP logo

prengine's Introduction

prengine

Contact me Build Status GitHub license

Poor Router Engine 一种用来帮助客户端实现更好的路由解决方案的rewrite引擎,可以用于客户端页面路由,模块解耦。

设计

通过prengine,你可以使用部分nginx语法来描写配置文件,prengine将会解析输入的URI,并根 据输入URI进行匹配,应用条件表达式,最后输出替换后的结果和规则。剩余的你可以使用Objective-C,Swift, 或是Java将prengine在iOS或是Android平台上进行封装。

示例

执行示例代码

g++ ../package/prengine_val.cpp ../package/cond_ast.cpp ../package/prengine.cpp  main.cpp
./a.out

安装

直接安装

拷贝package/目录下的prengine.h, prengine.cpp, prengine_val.h, prengine_val.cpp, cond_ast.h,
cond_ast.cpp到目标目录即可。

获取.a文件

进入package/目录 运行make 在bin/目录下获取.a文件。

获取ios平台.a文件

进入package/目录 运行make platform=ios 在bin/目录下获取.a文件。

使用

1.include "prengine.h"

2.调用PRFILE* pr_creat(char *cnt, VAL_HANDlER valhandler)来装载config文件

3.调用PRREWRITE* pr_rewrite_matched_creat(PRFILE *f,const char *uri) 传入PRFILE句柄和需要转化的URI,得到相应的PRREWRITE对象。

4.通过const char *pr_getserver(PRREWRITE *),const char *pr_getscheme(PRREWRITE *),const char *pr_getoutval(PRREWRITE *),const char *pr_getrule(PRREWRITE *) 来获取PRREWRITE对象的不同属性。

5.调用void pr_rewritefree(PRREWRITE *)释放PRREWRITE对象。

变量注入

如何在config文件中使用自定义变量(eg. 在config中使用$test)?

pr_id your_handler(const char *vname){
  if(strcmp(vname, "test") == 0){
      return pr_yes();
  }
  return pr_undefined();
}

pr_creat(f /*PRFILE句柄*/,your_handler);

prengine's People

Contributors

shenruisi avatar taofen8 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

prengine's Issues

prengine

sample.conf文件里配置第三种情况将无法被识别。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.