Slide 17
Slide 17 text
>
< 17
JJUG CCC 2016 Spring. 2016/05/21
URL ઃܭΛίʔυͰදݱ͓ͯ͘͠ʢ1ʣ
Ϣʔβը໘ɺཧը໘ɺAPIʢ֎͖ɺ͖ʣΛ enum Ͱఆٛ͢Δɻ
@AllArgsConstructor
@Getter
public enum Site {
API_INTERNAL("APIʢ͖ʣ", "/api/internal", false),
API_EXTERNAL("APIʢ֎͖ʣ", "/api", false),
SCREEN_ADMIN("ཧը໘", "/admin", true),
SCREEN_USER("Ϣʔβը໘", "", true);
private String label;
private String baseUrl;
private boolean protectCsrf;
// ྻڍࢠͷॱ൪Λม͑Δͱɺޡఆ͢ΔͷͰҙɻ
public static Site of(String url) {
if (url == null) {
return SCREEN_USER;
}
for (Site location : values()) {
if (url.startsWith(location.baseUrl)) {
return location;
}
}
return SCREEN_USER;
}
}
enum Ͱ URL ମܥΛఆٛ͢Δ
URL ͔ΒͲ͜ʹΞΫηε͍ͯ͠Δ͔
Λఆ͢ΔϝιουΛ༻ҙ͓ͯ͘͠