V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
windows98
V2EX  ›  问与答

怎么样优雅的维护 API 接口里面的各种客户端版本特殊逻辑

  •  
  •   windows98 · Sep 1, 2016 · 1038 views
    This topic created in 3530 days ago, the information mentioned may be changed or developed.
    这些接口为了兼容客户端版本出现了如下代码,每次有个什么升级基本就是怼代码,各自版本判断,平台判断。有啥优雅的方案解决

    if(VERSION > 1.0.0 && VERSION < 1.5.0) {
    $conf = "a_inc.php";
    } else if(VERSION >= 1.5.0) {
    $conf = "a_inc_new.php";
    }

    if(PLATFORM == "zh") {
    $conf = "b_inc.php";
    } else if (VERSION == "en") {
    $conf = "b_inc_new.php";
    }
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2507 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 78ms · UTC 08:40 · PVG 16:40 · LAX 01:40 · JFK 04:40
    ♥ Do have faith in what you're doing.