Update request mappings to use the new builder
This commit is contained in:
parent
ca1b4e3802
commit
a4eab715e9
@ -15,6 +15,7 @@ repositories {
|
||||
dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-actuator'
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
testImplementation('org.springframework.boot:spring-boot-starter-test') {
|
||||
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
|
||||
}
|
||||
|
@ -1,19 +1,57 @@
|
||||
package de.icaotix.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import de.icaotix.generator.PasswordBuilder;
|
||||
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.LinkedList;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
public class DefaultController {
|
||||
|
||||
@RequestMapping("/")
|
||||
public String index() {
|
||||
return "Greetings from Spring Boot, also from a Docker Container from Port 80!";
|
||||
public Map<Object, Object> index() {
|
||||
|
||||
Map<Object, Object> map = new HashMap<>();
|
||||
map.put("name", "PasswordAPI");
|
||||
map.put("endpoint", "/api");
|
||||
|
||||
Map<Object, Object> params = new HashMap<>();
|
||||
params.put("length", "int");
|
||||
params.put("upper", "[on | off]");
|
||||
params.put("lower", "[on | off]");
|
||||
params.put("number", "[on | off]");
|
||||
params.put("special", "[on | off]");
|
||||
params.put("exclude", "string");
|
||||
params.put("repeat", "int");
|
||||
|
||||
map.put("params", params);
|
||||
return map;
|
||||
}
|
||||
|
||||
// https://passwordwolf.com/?length=8&upper=off&lower=off&special=off&exclude=012345&repeat=20
|
||||
@RequestMapping("/api")
|
||||
public String standard() {
|
||||
return "password";
|
||||
public LinkedList<String> standard(
|
||||
@RequestParam(required = false, defaultValue = "8") int length,
|
||||
@RequestParam(required = false, defaultValue = "on") String upper,
|
||||
@RequestParam(required = false, defaultValue = "on") String lower,
|
||||
@RequestParam(required = false, defaultValue = "on") String number,
|
||||
@RequestParam(required = false, defaultValue = "off") String special,
|
||||
@RequestParam(required = false, defaultValue = "") String exclude,
|
||||
@RequestParam(required = false, defaultValue = "1") int repeat) {
|
||||
|
||||
return new PasswordBuilder()
|
||||
.setLength(length)
|
||||
.useUppercase(upper.equals("on"))
|
||||
.useLowercase(lower.equals("on"))
|
||||
.useNumbers(number.equals("on"))
|
||||
.useSpecial(special.equals("on"))
|
||||
.setExcludes(exclude)
|
||||
.setRepeat(repeat)
|
||||
.generate();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user