aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server/configuration/ActivityPubClientConfig.java
blob: d7d49355e3a52c96f10101db80baec4beb27b697 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.juick.server.configuration;

import com.juick.server.api.activity.model.Activity;
import com.juick.server.helpers.HeaderRequestInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import javax.inject.Inject;
import java.util.Collections;

@Configuration
public class ActivityPubClientConfig {
    @Inject
    ActivityPubClientErrorHandler activityPubClientErrorHandler;
    @Bean
    public RestTemplate apClient() {
        RestTemplate restTemplate = new RestTemplate();
        restTemplate.setErrorHandler(activityPubClientErrorHandler);
        restTemplate.setInterceptors(Collections.singletonList(
                new HeaderRequestInterceptor("Accept", Activity.ACTIVITY_MEDIA_TYPE)));
        return restTemplate;
    }
}