MCPcopy Index your code
hub / github.com/php/frankenphp / reject

Method reject

context.go:170–192  ·  view source on GitHub ↗

reject sends a response with the given status code and error

(err error)

Source from the content-addressed store, hash-verified

168
169// reject sends a response with the given status code and error
170func (fc *frankenPHPContext) reject(err error) {
171 if fc.isDone {
172 return
173 }
174
175 re := &ErrRejected{}
176 if !errors.As(err, re) {
177 // Should never happen
178 panic("only instance of ErrRejected can be passed to reject")
179 }
180
181 rw := fc.responseWriter
182 if rw != nil {
183 rw.WriteHeader(re.status)
184 _, _ = rw.Write([]byte(err.Error()))
185
186 if f, ok := rw.(http.Flusher); ok {
187 f.Flush()
188 }
189 }
190
191 fc.closeContext()
192}

Callers 3

validateMethod · 0.95
handleRequestMethod · 0.80

Calls 5

closeContextMethod · 0.95
WriteHeaderMethod · 0.80
FlushMethod · 0.80
WriteMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected