unsupport head method
zjj2wry opened this issue · comments
Jiajin Zheng commented
Is this a BUG REPORT or FEATURE REQUEST?:
Uncomment only one, leave it on its own line:
/kind bug
/kind feature
/cc @kdada
const (
// Head binds to http.MethodHead and code http.StatusOK(200)
Head definition.Method = "Head"
)
// ConsumeNoneForHTTPHead adds definition.MIMENone to consumes for head definitions.
// Then you don't need to manually write the consume to every head definitions.
// The head is http head rather than definition.Head.
func ConsumeNoneForHTTPHead() service.DefinitionModifier {
return func(d *definition.Definition) {
if service.HTTPMethodFor(d.Method) == http.MethodHead {
found := false
for _, v := range d.Consumes {
if v == definition.MIMENone {
found = true
break
}
}
if !found {
d.Consumes = append(d.Consumes, definition.MIMENone)
}
}
}
}
What happened:
What you expected to happen:
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
Jiajin Zheng commented
/assign @kdada
Wei Guo commented
Why is it necessary?
Jiajin Zheng commented
Used in the implementation of chunk download. current registered the head method by this function.
service.RegisterMethod(udef.Head, http.MethodHead, http.StatusOK)
Wei Guo commented
Actually you wanna add a new definition.Method(Head)
to Nirvana. So you need to do these things:
- Add the method to
definition
- Add a http mapping of the method to
service
- Add
ConsumeNoneForHTTPHead
andProduceNoneForHTTPHead
toservice
- Add the two functions to Nirvana project template
cmd/nirvana/project