Skip to content

Commit

Permalink
Alternative way to get images and CSS without an explicit method for …
Browse files Browse the repository at this point in the history
…each profile.

So now you can ask for

/v1/images/generic/favicon
/v1/images/ebrains/favicon

/v1/css/generic
/v1/css/ebrains

and content will be provided using a single method.
  • Loading branch information
annapaola committed Jul 3, 2024
1 parent f126586 commit 7a2ca50
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
11 changes: 4 additions & 7 deletions src/main/java/org/marmotgraph/cdn/generic/api/CSS.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
import org.marmotgraph.cdn.generic.utils.Constants;
import org.marmotgraph.cdn.generic.utils.Utils;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.io.InputStream;
Expand All @@ -17,10 +14,10 @@
@RequestMapping(value = "/"+Constants.API_VERSION+"/css", produces = Constants.TEXT_CSS)
public class CSS {

@GetMapping(value = "/generic")
@GetMapping(value = "/{type}")
@Operation(description = "This is the favicon to be used by all UIs")
public @ResponseBody byte[] generic() {
return Utils.getStaticResource("generic/generic.css");
public @ResponseBody byte[] cssResource(@PathVariable("type") String type) {
return Utils.getStaticResource(type + "/" + type + ".css");
}


Expand Down
12 changes: 4 additions & 8 deletions src/main/java/org/marmotgraph/cdn/generic/api/Images.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@
import io.swagger.v3.oas.annotations.Operation;
import org.marmotgraph.cdn.generic.utils.Constants;
import org.marmotgraph.cdn.generic.utils.Utils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/" + Constants.API_VERSION + "/images")
public class Images {

@GetMapping(value = "/favicon", produces = Constants.IMAGE_ICO)
@GetMapping(value = "/{type}/favicon", produces = Constants.IMAGE_ICO)
@Operation(description = "This is the favicon to be used by all UIs")
public @ResponseBody byte[] favicon() {
return Utils.getStaticResource("generic/favicon.ico");
public @ResponseBody byte[] favIconResource(@PathVariable("type") String type) {
return Utils.getStaticResource(type + "/favicon.ico");
}


}
4 changes: 4 additions & 0 deletions src/main/resources/org/marmotgraph/cdn/ebrains/ebrains.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
body {
background-color: green;

}
Binary file not shown.

0 comments on commit 7a2ca50

Please sign in to comment.