Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
haoqu.ma
/
gotty
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 36dfe5de
authored
Oct 04, 2015
by
Iwasaki Yudai
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #71 from moul/header-server
Add 'Server' HTTP header with current GoTTY version
2 parents
096f77c7
f75cc977
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletions
app/app.go
main.go
app/app.go
View file @
36dfe5d
...
@@ -53,6 +53,8 @@ type Options struct {
...
@@ -53,6 +53,8 @@ type Options struct {
Preferences
map
[
string
]
interface
{}
`hcl:"preferences"`
Preferences
map
[
string
]
interface
{}
`hcl:"preferences"`
}
}
var
Version
=
"0.0.10"
var
DefaultOptions
=
Options
{
var
DefaultOptions
=
Options
{
Address
:
""
,
Address
:
""
,
Port
:
"8080"
,
Port
:
"8080"
,
...
@@ -154,6 +156,8 @@ func (app *App) Run() error {
...
@@ -154,6 +156,8 @@ func (app *App) Run() error {
siteHandler
=
wrapBasicAuth
(
siteHandler
,
app
.
options
.
Credential
)
siteHandler
=
wrapBasicAuth
(
siteHandler
,
app
.
options
.
Credential
)
}
}
siteHandler
=
wrapHeaders
(
siteHandler
)
wsMux
:=
http
.
NewServeMux
()
wsMux
:=
http
.
NewServeMux
()
wsMux
.
Handle
(
"/"
,
siteHandler
)
wsMux
.
Handle
(
"/"
,
siteHandler
)
wsMux
.
Handle
(
path
+
"/ws"
,
wsHandler
)
wsMux
.
Handle
(
path
+
"/ws"
,
wsHandler
)
...
@@ -277,6 +281,13 @@ func wrapLogger(handler http.Handler) http.Handler {
...
@@ -277,6 +281,13 @@ func wrapLogger(handler http.Handler) http.Handler {
})
})
}
}
func
wrapHeaders
(
handler
http
.
Handler
)
http
.
Handler
{
return
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
w
.
Header
()
.
Set
(
"Server"
,
"GoTTY/"
+
Version
)
handler
.
ServeHTTP
(
w
,
r
)
})
}
func
wrapBasicAuth
(
handler
http
.
Handler
,
credential
string
)
http
.
Handler
{
func
wrapBasicAuth
(
handler
http
.
Handler
,
credential
string
)
http
.
Handler
{
return
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
return
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
token
:=
strings
.
SplitN
(
r
.
Header
.
Get
(
"Authorization"
),
" "
,
2
)
token
:=
strings
.
SplitN
(
r
.
Header
.
Get
(
"Authorization"
),
" "
,
2
)
...
...
main.go
View file @
36dfe5d
...
@@ -13,7 +13,7 @@ import (
...
@@ -13,7 +13,7 @@ import (
func
main
()
{
func
main
()
{
cmd
:=
cli
.
NewApp
()
cmd
:=
cli
.
NewApp
()
cmd
.
Version
=
"0.0.10"
cmd
.
Version
=
app
.
Version
cmd
.
Name
=
"gotty"
cmd
.
Name
=
"gotty"
cmd
.
Usage
=
"Share your terminal as a web application"
cmd
.
Usage
=
"Share your terminal as a web application"
cmd
.
HideHelp
=
true
cmd
.
HideHelp
=
true
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment