Skip to content

Instantly share code, notes, and snippets.

@biskandar
Created October 8, 2012 12:17
Show Gist options
  • Save biskandar/3852222 to your computer and use it in GitHub Desktop.
Save biskandar/3852222 to your computer and use it in GitHub Desktop.
Simplified webserver module using Webduino library 2012100803
// prepare for the default command request
void defaultCommand( WebServer &webserver , WebServer::ConnectionType connType , char *tailUrl , bool tailComplete ) {
Serial.print( "New Command: " ) ;
// first, accepting all kind of request
webserver.httpSuccess() ;
// validate based on http method,
// only GET or POST is allow to continue
Serial.print( "connType = " ) ;
Serial.print( connType ) ;
if ( ( connType != WebServer::GET ) && ( connType != WebServer::POST) ) {
Serial.println( "" ) ;
return ;
}
// print message response into the http response body
webserver.println( aJson.print( jsonResponse( "OK" , "OK" ) ) ) ;
// print the query string if found any
if ( strlen( tailUrl ) ) {
Serial.print( ", tailUrl = " ) ;
Serial.print( tailUrl ) ;
}
Serial.println( "" ) ;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment