-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.go
54 lines (46 loc) · 1.72 KB
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (C) 2015 Tim Retout <[email protected]>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// NNTP server. See RFC 3977.
package nntp
// A Handler can be registered to serve a particular group hierarchy
// in the NNTP server.
type Handler interface {
ServeNNTP(ResponseWriter, *Command)
}
// A ResponseWriter interface is used by an NNTP handler to
// construct an NNTP response.
type ResponseWriter interface {
// Write writes the data to the connection as part of an NNTP
// reply. If WriteHeader has not yet been called, Write calls
// WriteHeader(nntp.StatusOK) before writing the data.
Write([]byte) (int, error)
// WriteHeader sends an NNTP response header with status code.
// If WriteHeader is not called explicitly, the first call to Write
// will trigger an implicit WriteHeader(nntp.StatusInternalFault).
WriteHeader(int)
}
// A Server represents an NNTP server.
type Server struct {
}
type serverHandler struct {
}
func (*serverHandler) ServeNNTP(w ResponseWriter, c *Command) {
switch c.Keyword {
case "HELP":
w.WriteHeader(StatusHelpText)
w.Write([]byte("HELP - print this help"))
return
}
}