Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
f4322a84
Commit
f4322a84
authored
Mar 20, 2010
by
Andrew Gerrand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: add Error helper function
R=r, rsc CC=golang-dev
https://golang.org/cl/626042
parent
791a2673
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
src/pkg/http/server.go
src/pkg/http/server.go
+7
-4
No files found.
src/pkg/http/server.go
View file @
f4322a84
...
...
@@ -328,13 +328,16 @@ func (f HandlerFunc) ServeHTTP(c *Conn, req *Request) {
// Helper handlers
//
NotFound replies to the request with an HTTP 404 not found error
.
func
NotFound
(
c
*
Conn
,
req
*
Reques
t
)
{
//
Error replies to the request with the specified error message and HTTP code
.
func
Error
(
c
*
Conn
,
error
string
,
code
in
t
)
{
c
.
SetHeader
(
"Content-Type"
,
"text/plain; charset=utf-8"
)
c
.
WriteHeader
(
StatusNotFound
)
io
.
WriteString
(
c
,
"404 page not found
\n
"
)
c
.
WriteHeader
(
code
)
fmt
.
Fprintln
(
c
,
error
)
}
// NotFound replies to the request with an HTTP 404 not found error.
func
NotFound
(
c
*
Conn
,
req
*
Request
)
{
Error
(
c
,
"404 page not found"
,
StatusNotFound
)
}
// NotFoundHandler returns a simple request handler
// that replies to each request with a ``404 page not found'' reply.
func
NotFoundHandler
()
Handler
{
return
HandlerFunc
(
NotFound
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment