1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/mirrors-go-restful

Клонировать/Скачать
custom_verb.go 594 Байты
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
Vinci Xu Отправлено 11.09.2019 11:17 95fec02
package restful
import (
"fmt"
"regexp"
)
var (
customVerbReg = regexp.MustCompile(":([A-Za-z]+)$")
)
func hasCustomVerb(routeToken string) bool {
return customVerbReg.MatchString(routeToken)
}
func isMatchCustomVerb(routeToken string, pathToken string) bool {
rs := customVerbReg.FindStringSubmatch(routeToken)
if len(rs) < 2 {
return false
}
customVerb := rs[1]
specificVerbReg := regexp.MustCompile(fmt.Sprintf(":%s$", customVerb))
return specificVerbReg.MatchString(pathToken)
}
func removeCustomVerb(str string) string {
return customVerbReg.ReplaceAllString(str, "")
}

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/mirrors-go-restful.git
git@api.gitlife.ru:oschina-mirror/mirrors-go-restful.git
oschina-mirror
mirrors-go-restful
mirrors-go-restful
v3