This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.idspring.crudreactive.entity; | |
import lombok.AllArgsConstructor; | |
import lombok.Builder; | |
import lombok.Data; | |
import lombok.NoArgsConstructor; | |
import org.springframework.data.annotation.Id; | |
import org.springframework.data.mongodb.core.mapping.Document; | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependencies> | |
... | |
<dependency> | |
<groupId>org.projectlombok</groupId> | |
<artifactId>lombok</artifactId> | |
</dependency> | |
</dependencies> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.idspring.crudreactive.entity; | |
import org.springframework.data.annotation.Id; | |
import org.springframework.data.mongodb.core.mapping.Document; | |
/** | |
* @author Eko Kurniawan Khannedy | |
* @since 24/10/17 | |
*/ | |
@Document(collection = "products") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.idspring.crudreactive.entity; | |
import org.springframework.data.annotation.Id; | |
import org.springframework.data.mongodb.core.mapping.Document; | |
/** | |
* @author Eko Kurniawan Khannedy | |
* @since 24/10/17 | |
*/ | |
@Document(collection = "categories") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -v "http://localhost:8080/?secure=true" | |
* Hostname was NOT found in DNS cache | |
* Trying ::1... | |
* Connected to localhost (::1) port 8080 (#0) | |
> GET /?secure=true HTTP/1.1 | |
> User-Agent: curl/7.37.1 | |
> Host: localhost:8080 | |
> Accept: */* | |
> | |
< HTTP/1.1 200 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -v localhost:8080 | |
* Rebuilt URL to: localhost:8080/ | |
* Hostname was NOT found in DNS cache | |
* Trying ::1... | |
* Connected to localhost (::1) port 8080 (#0) | |
> GET / HTTP/1.1 | |
> User-Agent: curl/7.37.1 | |
> Host: localhost:8080 | |
> Accept: */* | |
> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
public class DemoConfiguration extends WebMvcConfigurerAdapter { | |
@Override | |
public void addInterceptors(InterceptorRegistry registry) { | |
// Add HandlerInterceptor to Registry | |
registry.addInterceptor(new DemoInterceptor()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DemoInterceptor extends HandlerInterceptorAdapter { | |
@Override | |
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { | |
String secure = request.getParameter("secure"); | |
if ("true".equals(secure)) { | |
return true; | |
} else { | |
response.setStatus(HttpStatus.UNAUTHORIZED.value()); | |
return false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface HandlerInterceptor { | |
boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) | |
throws Exception; | |
void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) | |
throws Exception; | |
void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) | |
throws Exception; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.idspring.commandpattern.service.command.impl; | |
import com.idspring.commandpattern.entity.Cart; | |
import com.idspring.commandpattern.entity.CartItem; | |
import com.idspring.commandpattern.entity.Product; | |
import com.idspring.commandpattern.model.service.AddProductToCartRequest; | |
import com.idspring.commandpattern.repository.CartRepository; | |
import com.idspring.commandpattern.repository.ProductRepository; | |
import com.idspring.commandpattern.service.AbstractCommand; | |
import com.idspring.commandpattern.service.command.AddProductToCartCommand; |