Skip to content

This is a library that can be used to parse the User Agent header in a Spring Boot 3 application.

Notifications You must be signed in to change notification settings

k143408/user-agent-parser-spring-boot-3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

user-agent-parser Spring boot 3 Library

This is a library that can be used to parse the User Agent header in a Spring Boot 3 application.

Import Dependency:

Maven

<dependency>
  <groupId>org.useragent.parse</groupId>
  <artifactId>resolver-spring-boot-3</artifactId>
  <version>1.0.0</version>
</dependency>

Gradle (Kotlin)

implementation("org.useragent.parse:resolver-spring-boot-3:1.0.0")

To build the project, execute

mvn package

Configuration:

import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.useragent.parse.DeviceResolverHandlerInterceptor;

class ResolverHandlerInterceptor implements WebMvcConfigurer {

  @Override
  public void addInterceptors(InterceptorRegistry registry) {
    registry
        .addInterceptor(new DeviceResolverHandlerInterceptor()).addPathPatterns(ALL);
  }
}

Usage:

import org.useragent.parse.Device;
import org.useragent.parse.DevicePlatform;
import org.useragent.parse.DeviceUtils;

Device device = DeviceUtils.getCurrentDevice(httpServletRequest);

device.isMobile() // true or false
device.isNormal() // true or false
device.isTablet() // true or false

DevicePlatform platform = device.getDevicePlatform();

About

This is a library that can be used to parse the User Agent header in a Spring Boot 3 application.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages