Skip to content

Commit

Permalink
Provide custom mime type for Unpoly
Browse files Browse the repository at this point in the history
  • Loading branch information
rainboyan committed May 7, 2024
1 parent d12cba4 commit 69835fa
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import javax.servlet.DispatcherType;

import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.web.servlet.ConditionalOnMissingFilterBean;
Expand All @@ -25,6 +26,8 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import grails.web.mime.MimeTypeProvider;

/**
* {@link EnableAutoConfiguration Auto-configuration} for Unpoly Plugin.
*
Expand All @@ -33,6 +36,7 @@
*/
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
@Configuration(proxyBeanMethods = false)
@AutoConfigureOrder(-100)
public class UnpolyAutoConfiguration {

@Bean
Expand All @@ -45,4 +49,9 @@ public FilterRegistrationBean<UnpolyRequestFilter> unpolyFilter() {
return registration;
}

@Bean
public MimeTypeProvider unpolyMimeTypeProvider() {
return new UnpolyMimeTypeProvider();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
*/
public class UnpolyMimeType {

public static final String UNPOLY_FORMAT = "unpoly";
public static final String UNPOLY_FORMAT = "up";

public static final MimeType UNPOLY = new MimeType("text/html+unpoly", "unpoly");
public static final MimeType UNPOLY = new MimeType("text/html", "up");

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright 2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.graceframework.plugins.unpoly;

import grails.web.mime.MimeType;
import grails.web.mime.MimeTypeProvider;

/**
* {@link MimeTypeProvider} for Unpoly
*
* @author Michael Yan
* @since 0.2
*/
public class UnpolyMimeTypeProvider implements MimeTypeProvider {

@Override
public MimeType[] getMimeTypes() {
return new MimeType[] { UnpolyMimeType.UNPOLY };
}

}

0 comments on commit 69835fa

Please sign in to comment.