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

com.github.bjuvensjo.rsimulator.http.config.HttpModule Maven / Gradle / Ivy

There is a newer version: 3.1.1
Show newest version
package com.github.bjuvensjo.rsimulator.http.config;

import java.util.HashMap;
import java.util.Map;

import com.google.inject.AbstractModule;
import com.google.inject.TypeLiteral;
import com.google.inject.name.Names;

/**
 * CoreModule holds Guice configurations.
 * 
 * @author Magnus Bjuvensjö
 */
public class HttpModule extends AbstractModule {

    /*
     * (non-Javadoc)
     * 
     * @see com.google.inject.AbstractModule#configure()
     */
    @Override
    protected void configure() {
        // ***** Simulator content types *****
        Map simulatorContentTypes = new HashMap();
        simulatorContentTypes.put("application/json", "json");
        simulatorContentTypes.put("application/xml", "xml");
        simulatorContentTypes.put("application/soap+xml", "xml");
        simulatorContentTypes.put("text/xml", "xml");
        simulatorContentTypes.put("default", "txt");

        bind(new TypeLiteral>() {
        }).annotatedWith(Names.named("simulatorContentTypes")).toInstance(simulatorContentTypes);

        // ***** Accepts *****
        Map accepts = new HashMap();
        accepts.put("application/json", "json");
        accepts.put("default", "txt");

        bind(new TypeLiteral>() {
        }).annotatedWith(Names.named("accepts")).toInstance(accepts);
        
        // ***** Response content types *****
        Map responseContentTypes = new HashMap();
        responseContentTypes.put("json", "application/json");
        responseContentTypes.put("txt", "text/plain");
        responseContentTypes.put("xml", "application/xml");
        responseContentTypes.put("default", "text/plain");

        bind(new TypeLiteral>() {
        }).annotatedWith(Names.named("responseContentTypes")).toInstance(responseContentTypes);        
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy