All Downloads are FREE. Search and download functionalities are using the official Maven repository.

restx.security.CORSHandler Maven / Gradle / Ivy

There is a newer version: 1.2.0-rc2
Show newest version
package restx.security;

import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import restx.*;
import restx.http.HttpStatus;

import java.io.IOException;

/**
 * Date: 28/12/13
 * Time: 11:33
 */
public class CORSHandler {
    private static final RestxHandler UNAUTHORIZED_HANDLER = new RestxHandler() {
        @Override
        public void handle(RestxRequestMatch match, RestxRequest req, RestxResponse resp, RestxContext ctx)
                throws IOException {
            resp.setStatus(HttpStatus.FORBIDDEN);
        }
    };

    protected Optional unauthorized(RestxRequest req) {
        return Optional.of(
                new RestxHandlerMatch(new StdRestxRequestMatch("*", req.getRestxPath(),
                        ImmutableMap.of(), ImmutableMap.of()), UNAUTHORIZED_HANDLER));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy