Blame view

src/main/java/com/peony/netty/http/Request.java 1.5 KB
f475e312   辛毅   create
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.peony.netty.http;

import com.peony.netty.web.PathMatchResult;
import com.peony.util.StringUtils;
import io.netty.handler.codec.http.HttpRequest;

import java.util.Map;

public class Request {

    private HttpRequest request;
    private Map<String, String> params;
    private PathMatchResult pathMatchResult;
    private String[] customPaths;

    public Request(HttpRequest request) {
        this.request = request;
    }

    public HttpRequest getRequest() {
        return request;
    }

    public void setRequest(HttpRequest request) {
        this.request = request;
    }

    public Map<String, String> getParams() {
        return params;
    }

    public void setParams(Map<String, String> params) {
        this.params = params;
    }

    public PathMatchResult getPathMatchResult() {
        return pathMatchResult;
    }

    public String[] getCustomPaths() {
        return customPaths;
    }

    public void setCustomPath(String[] customPaths) {
        this.customPaths = customPaths;
    }

    public void setPathMatchResult(PathMatchResult pathMatchResult) {
        this.pathMatchResult = pathMatchResult;
        if (params == null) {
            this.params = pathMatchResult.getParams();
        }
        if (customPaths == null) {
            this.customPaths = pathMatchResult.getCustomPaths();
        }
    }

    public String params(String key) {
        if (StringUtils.isEmpty(key) || params == null) {
            return null;
        }
        return params.get(key);
    }
}