summaryrefslogtreecommitdiffstats
path: root/container-core/src/main/java/com/yahoo/container/jdisc/DefaultAclMapping.java
blob: 936390291284797316d782646c476dd9df6c893f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

package com.yahoo.container.jdisc;

/**
 * Default ACL mapping
 * @author mortent
 */
public class DefaultAclMapping implements AclMapping {

    @Override
    public Action get(RequestView requestMeta) {
        switch (requestMeta.method()) {
            case GET:
            case HEAD:
            case OPTIONS:
                return Action.READ;
            case POST:
            case DELETE:
            case PUT:
            case PATCH:
            case CONNECT:
            case TRACE:
                return Action.WRITE;
            default:
                throw new IllegalArgumentException("Illegal request method: " + requestMeta.method());
        }
    }
}