Skip to content
Permalink
Browse files
react frontend added
  • Loading branch information
fiammara committed Jan 20, 2020
1 parent 3338e86 commit 363864f7176cdd7ed883ebe0fe086eead9b43f85
Showing 5 changed files with 25 additions and 5 deletions.
@@ -12,11 +12,15 @@
// ***************************************************************************************************************************
package org.apache.juneau.petstore;

import java.util.Arrays;

import org.apache.juneau.petstore.rest.*;
import org.apache.juneau.petstore.service.*;
import org.apache.juneau.rest.springboot.annotation.JuneauRestRoot;
import org.springframework.boot.web.servlet.*;
import org.springframework.context.annotation.*;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.*;

@SuppressWarnings("javadoc")
@@ -60,4 +64,15 @@ public FilterRegistrationBean<HiddenHttpMethodFilter> registration(HiddenHttpMet
registration.setEnabled(false);
return registration;
}
@Bean
public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.addAllowedOrigin("*");
config.setAllowedMethods(Arrays.asList("POST", "OPTIONS", "GET", "DELETE", "PUT"));
config.setAllowedHeaders(Arrays.asList("X-Requested-With", "Origin", "Content-Type", "Accept", "Authorization"));
source.registerCorsConfiguration("/**", config);
return new CorsFilter(source);
}
}
@@ -27,9 +27,11 @@ protected void configure(HttpSecurity http) throws Exception {
.httpBasic()
.and()
.authorizeRequests()
.anyRequest().authenticated()
.antMatchers(GET).anonymous() // Allow anonymous read-only access.
.antMatchers(POST).anonymous() // TEMPORARY.
.antMatchers(GET).permitAll()
.antMatchers(POST).permitAll()
//.anyRequest().authenticated()
//.antMatchers(GET).anonymous() // Allow anonymous read-only access.
//.antMatchers(POST).anonymous() // TEMPORARY.
.and()
.csrf().disable()
.formLogin().disable();
@@ -36,6 +36,7 @@
import org.apache.juneau.http.response.*;
import org.apache.juneau.rest.widget.*;
import org.apache.juneau.transforms.*;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.apache.juneau.rest.converters.*;

/**
@@ -188,6 +189,7 @@ public Collection<Pet> getPets() throws NotAcceptable {
}

@Override /* PetStore */
@CrossOrigin(origins = "http://localhost:3000", maxAge = 3600)
@RestMethod(
name=GET,
path="/pet/{petId}",
@@ -56,12 +56,12 @@
"</div>"
}
)
@SerializerConfig(
/*@SerializerConfig(
// For testing purposes, we want to use single quotes in all the serializers so it's easier to do simple
// String comparisons.
// You can apply any of the Serializer/Parser/BeanContext settings this way.
quoteChar="'"
)
) */
public class RootResources extends BasicRestServletGroup {
private static final long serialVersionUID = 1L;
}
1 pets
Submodule pets added at 56287f

0 comments on commit 363864f

Please sign in to comment.