Skip to content

Instantly share code, notes, and snippets.

@chkal
Created July 31, 2013 06:19
Show Gist options
  • Save chkal/6119756 to your computer and use it in GitHub Desktop.
Save chkal/6119756 to your computer and use it in GitHub Desktop.
Simple Servlet to control Togglz features using GET requests
@WebServlet(urlPatterns = "/FeatureServlet")
public class FeatureServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@Override
protected void doGet( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException {
Feature feature = new NamedFeature( req.getParameter( "feature" ) );
boolean enabled = "on".equals( req.getParameter( "state" ) );
FeatureState state = new FeatureState( feature )
.setEnabled( enabled );
FeatureContext.getFeatureManager().setFeatureState( state );
resp.getOutputStream().println( "OK" );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment