This repository has been archived by the owner on Apr 25, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prior to this commit, the webhook endpoint would be protected by CSRF, preventing all existing integration from working. This commit selectively disables CSRF protection on this endpoint, and rewrites completely the Controller in order to simplify it.
- Loading branch information
Showing
15 changed files
with
428 additions
and
469 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package sagan.site.guides; | ||
|
||
import java.util.Arrays; | ||
|
||
/** | ||
* Guide Types | ||
*/ | ||
enum GuideType { | ||
|
||
GETTING_STARTED("getting-started", "gs-"), TUTORIAL("tutorial", "tut-"), | ||
TOPICAL("topical", "top-"), UNKNOWN("unknown", ""); | ||
|
||
private final String slug; | ||
private final String prefix; | ||
|
||
|
||
GuideType(String slug, String prefix) { | ||
this.slug = slug; | ||
this.prefix = prefix; | ||
} | ||
|
||
public static GuideType fromSlug(String slug) { | ||
return Arrays.stream(GuideType.values()) | ||
.filter(type -> type.getSlug().equals(slug)) | ||
.findFirst().orElse(GuideType.UNKNOWN); | ||
} | ||
|
||
public static GuideType fromRepositoryName(String repositoryName) { | ||
return Arrays.stream(GuideType.values()) | ||
.filter(type -> repositoryName.startsWith(type.getPrefix())) | ||
.findFirst().orElse(GuideType.UNKNOWN); | ||
} | ||
|
||
public String stripPrefix(String repositoryName) { | ||
return repositoryName.replaceFirst(this.prefix, ""); | ||
} | ||
|
||
public String getSlug() { | ||
return this.slug; | ||
} | ||
|
||
public String getPrefix() { | ||
return this.prefix; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return this.slug; | ||
} | ||
} |
Oops, something went wrong.