cf.adriantodt.David.modules.rest.SetController.java Source code

Java tutorial

Introduction

Here is the source code for cf.adriantodt.David.modules.rest.SetController.java

Source

/*
 * This class was created by <AdrianTodt>. It's distributed as
 * part of the DavidBot. Get the Source Code in github:
 * https://github.com/adriantodt/David
 *
 * DavidBot is Open Source and distributed under the
 * GNU Lesser General Public License v2.1:
 * https://github.com/adriantodt/David/blob/master/LICENSE
 *
 * File Created @ [07/11/16 20:36]
 */

package cf.adriantodt.David.modules.rest;

import com.google.gson.JsonElement;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;

@RestController
public class SetController {
    public static final Map<String, Function<Map<String, String>, JsonElement>> api = new HashMap<>();

    static {
    }

    @RequestMapping("/set")
    public String api(@RequestParam Map<String, String> params) {
        return api.getOrDefault(params.getOrDefault("type", ""), WebInterfaceHelper.API_CALL_NOT_FOUND)
                .apply(params).toString();
    }
}