Mercurial Hosting > luan
view src/goodjava/webserver/handlers/RegexHandler.java @ 2082:cdc9a31c6f71 ssltesting
update renewSsl.sh to reflect changes in directory structure
| author | Violet7 |
|---|---|
| date | Tue, 09 Dec 2025 17:53:16 -0800 |
| parents | f7e3adae4907 |
| children |
line wrap: on
line source
package goodjava.webserver.handlers; import java.util.regex.Pattern; import goodjava.webserver.Handler; import goodjava.webserver.Request; import goodjava.webserver.Response; public final class RegexHandler implements Handler { private final Pattern ptn; private final Handler ifMatch; private final Handler ifNotMatch; public RegexHandler(Pattern ptn,Handler ifMatch,Handler ifNotMatch) { this.ptn = ptn; this.ifMatch = ifMatch; this.ifNotMatch = ifNotMatch; } public RegexHandler(String ptn,Handler ifMatch,Handler ifNotMatch) { this(Pattern.compile(ptn),ifMatch,ifNotMatch); } public Response handle(Request request) { return ptn.matcher(request.path).find() ? ifMatch.handle(request) : ifNotMatch.handle(request); } }
