

Spark web server - rif
https://github.com/rif/spark
Little web server for emergencies
======
rektide
As opposed to Spark, the microcontroller platform. As opposed to Spark, the
resilient distributed data system. As opposed to Spark, the open source IM
client.

~~~
Zikes
Yep, should've gone with Zitser or Poppler.

~~~
drv
You were probably being facetious, but Poppler is already used too (PDF
rendering library).

~~~
agret
Would've made more sense for a POP email library.

------
dangerlibrary
Is it really that hard to add 5 lines of boilerplate to your nginx conf? You
can probably just copy-paste an existing server{} block or sites-available
file and change the root directory. As a bonus, you'll learn a bit about how
to configure the same tool you'll use later in production.

Oh. It's written in Go. Got it.

~~~
sanderjd
I'm so sick of seeing this pattern of 1) person makes tool they find useful,
2) person releases tool publicly _for free_ , 3) other person comes across
tool but doesn't find it useful, 4) other person publicly denigrates tool as
being universally not-useful.

I just don't get it.

~~~
dangerlibrary
I don't think I said anything negative about the tool itself, or about the
author of the tool, who seems perfectly happy with it.

You're right that I don't think it's useful to have a proliferation of tools
that do one thing worse than a general-purpose tool.

I don't want an avocado peeler - I'll use a knife and I'll recommend using a
knife to others.

~~~
mverwijs
Great. Good for you.

Your initial comment, however, is filled with a denigrating tone. It is that
tone your parent is addressing. Not so much the content. The tone. It is
unkind.

------
raimue
You could achieve something similar using the simple HTTP server shipped with
python: python -m SimpleHTTPServer

~~~
kordless
Which will melt with any sort of sustained traffic.

~~~
hysan
Except, that's not the use case for Spark so it's an apt comparison.

> Emergency web server

> For those occasions when your webserver is down and you want to display a
> quick maintainance note. Or just want to quickly demo a static site. Or
> whatever :)

~~~
dkuntz2
Yes it is. The use case is when your site is down and you want to tell people
that. If you have even a small amount of traffic `python -m http.server` is
going to die, this isn't.

How is that not an apt comparison?

------
dewey
If you just want a small httpd there's also gatling and fnord.

[0] [http://www.fefe.de/gatling/](http://www.fefe.de/gatling/) [1]
[http://www.fefe.de/fnord/](http://www.fefe.de/fnord/)

~~~
rif
this one has 45 lines of code :)

~~~
bestham
Well, the binary contains a lot of go.

~~~
dkuntz2
That's true of anything written in Go.

~~~
ploxiln
Yes, but, trivial c programs statically linked with glibc can be in the
ballpark of 500KiB, trivial c programs statically linked with uclibc or
similar can be in the ballpark of 100KiB, and trivial go programs (always
statically compiled) can be 2-5 MiB. They're huge.

~~~
rif
The go team is aware of this and I think it will improve soon:
[http://talks.golang.org/2014/go1.3.slide#1](http://talks.golang.org/2014/go1.3.slide#1)

------
michaelmior
I was wondering why I would want this, but being able to pass some HTML on the
command line is pretty cool.

------
Alan_
I can't see anywhere in the code so assume this returns a 200 code for
requests. If was using this to show maintenance for my website would want it
to return 503.

~~~
rif
Added a parameter to stet the desired status

------
jjoe
python -m SimpleHTTPServer 8080

Above will serve whatever files you have in $PWD

~~~
dbpatterson
And be _insanely_ slow (not just the normal, python is slow comment - there
are fast web servers in python; SimpleHTTPServer is not).

------
incidence
Thanks! I have have been using "python -m SimpleHTTPServer" a lot, it is kind
of a pain in the ass since it hangs sometimes in a weird way.

------
swah
Can someone explain this function signature? I can't grep it.

func (h bytesHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

~~~
zek
you have to get used to get go's backwards type declaration. This is defining
a method on h which is a byteHandler struct called serve which takes a
http.ResponseWriter and Request and returns nothing.

This is from the http.Handler interface, so defining this method causes
byteHandler to conform to the http.Handler interface.

~~~
zaphar
byteHandler is not a struct it's a byte slice. This is actually somewhat
important since it highlights a nice feature of go where you can declare
methods on any baseType by aliasing them to your own type.

There is no struct involved here and there doesn't need to be which is nice.

~~~
ihsw
I've found that when discussing Go, the terms `struct` and `type` are usually
used interchangeably. Yes it's factually incorrect, but the message is at
least intelligible.

